1
我試圖讓它在文本框中輸入數字,然後按下按鈕。一個字符串然後等於文本字段,然後標籤等於字符串。問題是當我按下按鈕時它崩潰。我究竟做錯了什麼?
如何設置字符串值等於UITextField?
從.h文件:
@interface TextGameViewController : UIViewController
{
IBOutlet UITextField *input;
IBOutlet UILabel *line11;
NSString *l11;
}
-(IBAction)button;
從.m文件:
-(IBAction)button
{
[input resignFirstResponder];
l11 = ([input.text stringValue]);
line11.text = [[NSString alloc] initWithFormat:@"%2.f", l11];
}