Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,027

HOME > Mobile > Mobile Forum > How to uitextfield value pass one uiviewcontroller to another uiviewcontroller.



 

How to uitextfield value pass one uiviewcontroller to another uiviewcontroller.

 



Topic : 098035



โพสกระทู้ ( 274 )
บทความ ( 0 )



สถานะออฟไลน์




How to uitextfield value pass one uiviewcontroller to another uiviewcontroller.

I use this method.

// ViewController.h
Code (Objective-C)


#import <UIKit/UIKit.h>

@interface ViewController : UIViewController
{
   IBOutlet UITextField *txtName;
   IBOutlet UITextField *txtLastname;
   IBOutlet UITextField *txtphone;
   IBOutlet UITextField *txtdesc;
 
  }

@property(nonatomic,assign) NSMutableData *receivedData;
@property(nonatomic,retain) UITextField *txtName;
@property(nonatomic,retain) UITextField *txtLastname;
@property(nonatomic,retain) UITextField *txtphone;
@property(nonatomic,retain) UITextField *txtdesc;

- (IBAction)btnSearch:(id)sender;

@end



// ViewController.m

Code (Objective-C)
#import "ViewController.h"
#import "sample.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize receivedData;
@synthesize txtphone, txtdesc, txtLastname, txtName;

- (void)viewDidLoad
{
    [super viewDidLoad];
	
}

- (IBAction)btnSearch:(id)sender{
    sample *next = [[sample alloc]init];
    next.txtName = txtName.text;
    next.txtLastname = txtLastname.text;
    next.txtphone = txtphone.text;
    next.txtdesc = txtdesc.text;
    [self presentViewController:next animated:YES completion:nil];
}




// sample.h

Code (Objective-C)
#import <UIKit/UIKit.h>

@interface sample : UIViewController <UITableViewDataSource,UITableViewDelegate>
{
    IBOutlet UITableView *myTable;

}
@property (strong, nonatomic) id txtphone;
@property (strong, nonatomic) id txtdesc;
@property (strong, nonatomic) id txtLastname;
@property (strong, nonatomic) id txtName;

@property(nonatomic,assign) NSMutableData *receivedData;


@end


// sample.m

Code (Objective-C)
import "sample.h"

@interface sample ()
{
    NSMutableArray *myObject;
    
    // A dictionary object
    NSDictionary *dict;
    
    // Define keys
    NSString *memberid;
    NSString *name;
    NSString *tel;
    
    UIAlertView *loading;
}
@end

@implementation sample

@synthesize receivedData;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    NSMutableString *post = [NSString stringWithFormat:@"Name=%@&lastname=%@&Tel=%@&Description=%@",_txtName,_txtLastname,_txtphone,_txtdesc];
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
    
    NSURL *url = [NSURL URLWithString:@"http://localhost/api/search.php"];
    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
                                                           cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
                                                       timeoutInterval:10.0];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
	[request setHTTPBody:postData];
    
    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
    
    // Show Progress Loading...
    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
    
    loading = [[UIAlertView alloc] initWithTitle:@"" message:@"Please Wait..." delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
    UIActivityIndicatorView *progress= [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
    [loading addSubview:progress];
    [progress startAnimating];
    [progress release];
    [loading show];
    
    if (theConnection) {
        self.receivedData = [[NSMutableData data] retain];
    } else {
		UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"NSURLConnection " message:@"Failed in viewDidLoad"  delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
		[connectFailMessage show];
		[connectFailMessage release];
    }
    
    [myTable reloadData];

}




but this is going to exception
2013-07-19 16:59:48.637 search[8306:c07] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSDictionary dictionaryWithObjectsAndKeys:]: second object of each pair must be non-nil. Or, did you forget to nil-terminate your parameter list?'
*** First throw call stack:
(0x1c97012 0x10d4e7e 0x1c783b8 0x4014 0xbda589 0xbd8652 0xbd989a 0xbd860d 0xbd8785 0xb25a68 0x4619911 0x4618bb3 0x4656cda 0x1c398fd 0x465735c 0x46572d5 0x4541250 0x1c1af3f 0x1c1a96f 0x1c3d734 0x1c3cf44 0x1c3ce1b 0x1bf17e3 0x1bf1668 0x18ffc 0x274d 0x2675)
libc++abi.dylib: terminate called throwing an exception




Tag : Mobile, iOS, iPhone, Objective-C







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2013-07-19 18:32:09 By : vishwa View : 1055 Reply : 3
 

 

No. 1



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook

Quote:
reason: '+[NSDictionary dictionaryWithObjectsAndKeys:]:


Check the key/value in NSDictionary






แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-07-19 21:24:04 By : mr.win
 


 

No. 2



โพสกระทู้ ( 274 )
บทความ ( 0 )



สถานะออฟไลน์


Thanks mr.win now working perfectly
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-07-22 11:26:40 By : vishwa
 

 

No. 3



โพสกระทู้ ( 74,058 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2013-07-22 12:44:50 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : How to uitextfield value pass one uiviewcontroller to another uiviewcontroller.
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

Load balance : Server 05
ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2024 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่