在Xcode 4.3 3中,我創建了一個按鈕,它生成一個彈出式輸入框(按鈕取消&回車),工作正常,如何檢索輸入的數據並將其顯示在標籤中或表?從UIAlertView檢索輸入文本
下面是我的按鈕背後的代碼的樣子。
- (IBAction)car:(UIButton *) sender
NSString * title1 = [sender titleForState:UIControlStateNormal];
_mylabel.text = title1;
UIAlertView *prompt = [[UIAlertView alloc] initWithTitle:@"Expense Amount in $:"
message:@"\n\n"
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"Enter", nil];
_textField = [[UITextField alloc] initWithFrame:CGRectMake(12, 50, 260, 25)];
[_textField setBackgroundColor:[UIColor whiteColor]];
[_textField setPlaceholder:@"Amount"];
[prompt addSubview:_textField];
_textField.keyboardType = UIKeyboardTypeNumberPad;
// show the dialog box
[prompt show];
// set cursor and show keyboard
[_textField becomeFirstResponder];
}
謝謝你的幫助。
嗨jaydee3,thx爲你的迴應,我是新來的這一切,可以幫助我如何執行這個去? Thx再次。 – Diffrey 2012-07-15 05:04:23
查看本教程的實現:http://mobile.tutsplus.com/tutorials/iphone/ios-5-sdk-uialertview-text-input-and-validation/ – calimarkus 2012-07-15 11:07:48