0

私の .h ファイルでは、テキスト フィールドとラベルの両方にプロパティを設定しました。

@property (retain, nonatomic) IBOutlet UITextField *phoneNumberEntry;
@property (retain, nonatomic) IBOutlet UILabel *testLabel;

また、それらを .m ファイルに合成しました。

@synthesize phoneNumberEntry;
@synthesize testLabel;

テキストビューの内容を変数に保存してから、ラベルに表示するにはどうすればよいですか?

4

2 に答える 2

0

必要なことは、UITextField のテキストを保持する文字列変数を作成することです。

NSString *textString = phoneNumberEntry.text;

あとは、作成した文字列変数を使用してラベルのテキストを設定するだけです

testLabel.text = textString;

EDIT: If you're having trouble hooking it up in IB, just go to the files owner, and then click on the identity inspector, and find the box that says "class:" or something similar. THis is where you're going to type in your class. Once typed in, just hit enter, and then go to the connections inspector. This will allow you to see the properties you have created in your .h file.

Hope this helps!

于 2013-08-21T00:35:50.353 に答える