2012-05-06 17 views
0

XCodeのUITextFieldの

@interface MyController : UIViewController<UITextFieldDelegate> { 

    IBOutlet UITextField *phonenum; 
    IBOutlet UITextField *email; 
} 

@property (nonatomic, retain) UITextField *phonenum; 
@property (nonatomic, retain) UITextField *email; 

-(IBAction) btnClicked: (id) sender; 
@end 

.M内側:私が間違って何をし

-(IBAction) btnClicked: (id) sender{ 


NSString *str = [[NSString alloc]init]; 
NSLog(@"str=%@",str); //this contains valid value 
email.text=str; /// does not set the value 
[[self email] setText: str]; // does not set the value 
} 

をやっていることは、変数strのを使用してUITextFieldの値を設定しない場合それはNSStringですか?これはある種のInteface Builder設定ですか?私はファイル所有者へのリンクを委任しました。

+1

あなたがインターフェイスであなたの店をリンクしましたビルダー? –

+0

TDeBailleulありがとうございました。電子メール(UITextField)と電話(UITextField)のReference Outletをリンクしていませんでした。 – user1119116

+0

[OK]を、私は答えを追加したので、それを受け入れることができ、あなたの質問を '解決' –

答えて

2

strがnilなので、何も起こりません。あなたの最後の2行は同じことをします。 あなたが

NSString *str = email.text;

を書き、そしてあなたがユーザーの電子メールを更新する場合は

user.email = str;

または直接

user.email = email.text

のように、STRで何かを行う必要がありますあなたのUITextFieldのテキスト