代码:
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Name your Search" message:@"Save Search as" delegate:nil cancelButtonTitle:@"Cancel" otherButtonTitles:@"Ok", nil] ;
alertView.tag = 20;
alertView.delegate = self;
alertView.cancelButtonIndex = 1;
alertView.alertViewStyle = UIAlertViewStylePlainTextInput;
[alertView show];
- (BOOL)alertViewShouldEnableFirstOtherButton:(UIAlertView *)alertView
{
if(alertView.tag == 20){
UITextField *textField = [alertView textFieldAtIndex:0];
textField.text = @"testing";
if ([textField.text length] == 0){
return NO;
}
}
return YES;
}
我创建了一个带有 TEXTINPUT 模式的 UIALERVIEW。我确实在文本框中设置了文本值。它不允许我在出现警报 View 时编辑文本字段值。我的代码有什么问题?提前致谢
最佳答案
添加这一行:textField.userInteractionEnabled = YES;
在这一行之后:textField.text = @"testing";
关于iOS 编辑 Uialertview 的 TextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29863859/