【发布时间】:2014-04-21 07:57:28
【问题描述】:
您好,我正在尝试查看 UIAlertView 中的两个文本字段,但显示错误。我已经使用下面的代码来查看文本字段。
- (void)viewDidLoad
{
[super viewDidLoad];
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:@"Hello!"
message:@"Please enter your details:"
delegate:self
cancelButtonTitle:@"Continue"
otherButtonTitles:nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
UITextField * name = [alert textFieldAtIndex:0];
name.keyboardType = UIKeyboardTypeAlphabet;
name.placeholder = @"Enter your name";
UITextField * phone = [alert textFieldAtIndex:1];
phone.keyboardType = UIKeyboardTypeNumberPad;
phone.placeholder = @"Enter your phone";
[alert show];
[alert release];
}
我已经使用上面的代码查看了两个文本文件,但我越来越喜欢了。 'textFieldIndex (1) 超出了文本字段数组的范围'
请告诉我我在上面的代码中哪里做错了,请告诉我要解决这个问题。
【问题讨论】:
标签: ios objective-c ios7 uialertview