当我向下拉tableView
时,alertView
应显示一个登录文字字段。
警报必须到来,但不能选择textField
点击此textField
后,键盘就会出现。
为此,我使用此代码:
- (void)toggleCells:(UIRefreshControl*)refreshControl
{
message = [[UIAlertView alloc] initWithTitle:@"Create a new list"
message:@""
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[message setAlertViewStyle:UIAlertViewStylePlainTextInput];
[message setTag:1001];
//[message textFieldAtIndex:0].delegate = self;
[refreshControl beginRefreshing];
[message show];
[refreshControl endRefreshing];
//...
}
答案 0 :(得分:0)
试试这个
UIAlertView *av = [[UIAlertView alloc]initWithTitle:@"SayWhat" message:@"Please enter Email address" delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil];
av.alertViewStyle = UIAlertViewStylePlainTextInput;
[av setAlertViewStyle:UIAlertViewStylePlainTextInput];
[[av textFieldAtIndex:0] setPlaceholder:@"Email address"];
[[av textFieldAtIndex:0] setDelegate:self];
[av show];
[[av textFieldAtIndex:0] resignFirstResponder];
答案 1 :(得分:0)
尝试:( 不太好,但快速修复)
message = [[UIAlertView alloc] initWithTitle:@"Create a new list"
message:nil
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[message setAlertViewStyle:UIAlertViewStylePlainTextInput];
[message setTag:1001];
[[message textFieldAtIndex:0] setDelegate:self]; //you'll surely need it later
[message show];
[[message textFieldAtIndex:0] resignFirstResponder]; //after showing the alertView
注意:上面的方法并不是很好。
注意:在BOOL skipAlertTextField;
.h
”
- (void)toggleCells:(UIRefreshControl*)refreshControl {
//...
message = [[UIAlertView alloc] initWithTitle:@"Create a new list"
message:nil
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"OK", nil];
[message setAlertViewStyle:UIAlertViewStylePlainTextInput];
[message setTag:1001];
[[message textFieldAtIndex:0] setDelegate:self];
skipAlertTextField = YES; //important
[message show];
//...
}
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField {
if(textField.tag == 1001 && skipAlertTextField) {
skipAlertTextField = NO;
return NO;
}
return YES;
}