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,038

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



 

[Mobile] 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)
01.#import <UIKit/UIKit.h>
02. 
03.@interface ViewController : UIViewController
04.{
05.   IBOutlet UITextField *txtName;
06.   IBOutlet UITextField *txtLastname;
07.   IBOutlet UITextField *txtphone;
08.   IBOutlet UITextField *txtdesc;
09.  
10.  }
11. 
12.@property(nonatomic,assign) NSMutableData *receivedData;
13.@property(nonatomic,retain) UITextField *txtName;
14.@property(nonatomic,retain) UITextField *txtLastname;
15.@property(nonatomic,retain) UITextField *txtphone;
16.@property(nonatomic,retain) UITextField *txtdesc;
17. 
18.- (IBAction)btnSearch:(id)sender;
19. 
20.@end


// ViewController.m

Code (Objective-C)
01.#import "ViewController.h"
02.#import "sample.h"
03. 
04.@interface ViewController ()
05. 
06.@end
07. 
08.@implementation ViewController
09. 
10.@synthesize receivedData;
11.@synthesize txtphone, txtdesc, txtLastname, txtName;
12. 
13.- (void)viewDidLoad
14.{
15.    [super viewDidLoad];
16.     
17.}
18. 
19.- (IBAction)btnSearch:(id)sender{
20.    sample *next = [[sample alloc]init];
21.    next.txtName = txtName.text;
22.    next.txtLastname = txtLastname.text;
23.    next.txtphone = txtphone.text;
24.    next.txtdesc = txtdesc.text;
25.    [self presentViewController:next animated:YES completion:nil];
26.}



// sample.h

Code (Objective-C)
01.#import <UIKit/UIKit.h>
02. 
03.@interface sample : UIViewController <UITableViewDataSource,UITableViewDelegate>
04.{
05.    IBOutlet UITableView *myTable;
06. 
07.}
08.@property (strong, nonatomic) id txtphone;
09.@property (strong, nonatomic) id txtdesc;
10.@property (strong, nonatomic) id txtLastname;
11.@property (strong, nonatomic) id txtName;
12. 
13.@property(nonatomic,assign) NSMutableData *receivedData;
14. 
15. 
16.@end


// sample.m

Code (Objective-C)
01.import "sample.h"
02. 
03.@interface sample ()
04.{
05.    NSMutableArray *myObject;
06.     
07.    // A dictionary object
08.    NSDictionary *dict;
09.     
10.    // Define keys
11.    NSString *memberid;
12.    NSString *name;
13.    NSString *tel;
14.     
15.    UIAlertView *loading;
16.}
17.@end
18. 
19.@implementation sample
20. 
21.@synthesize receivedData;
22. 
23.- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
24.{
25.    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
26.    if (self) {
27.        // Custom initialization
28.    }
29.    return self;
30.}
31. 
32.- (void)viewDidLoad
33.{
34.    [super viewDidLoad];
35.    // Do any additional setup after loading the view from its nib.
36.     
37.    NSMutableString *post = [NSString stringWithFormat:@"Name=%@&lastname=%@&Tel=%@&Description=%@",_txtName,_txtLastname,_txtphone,_txtdesc];
38.    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
39.    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];
40.     
41.    NSURL *url = [NSURL URLWithString:@"http://localhost/api/search.php"];
42.    NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url
43.                                                           cachePolicy:NSURLRequestReloadIgnoringLocalCacheData
44.                                                       timeoutInterval:10.0];
45.    [request setHTTPMethod:@"POST"];
46.    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
47.    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
48.    [request setHTTPBody:postData];
49.     
50.    NSURLConnection *theConnection=[[NSURLConnection alloc] initWithRequest:request delegate:self];
51.     
52.    // Show Progress Loading...
53.    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
54.     
55.    loading = [[UIAlertView alloc] initWithTitle:@"" message:@"Please Wait..." delegate:nil cancelButtonTitle:nil otherButtonTitles:nil];
56.    UIActivityIndicatorView *progress= [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 50, 30, 30)];
57.    progress.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge;
58.    [loading addSubview:progress];
59.    [progress startAnimating];
60.    [progress release];
61.    [loading show];
62.     
63.    if (theConnection) {
64.        self.receivedData = [[NSMutableData data] retain];
65.    } else {
66.        UIAlertView *connectFailMessage = [[UIAlertView alloc] initWithTitle:@"NSURLConnection " message:@"Failed in viewDidLoad"  delegate: self cancelButtonTitle:@"Ok" otherButtonTitles: nil];
67.        [connectFailMessage show];
68.        [connectFailMessage release];
69.    }
70.     
71.    [myTable reloadData];
72. 
73.}



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