Objective c UIAlertController中未添加UIExtField
UIAlertController中未添加UIExtField 这是我的密码:Objective c UIAlertController中未添加UIExtField,objective-c,iphone,xcode9,Objective C,Iphone,Xcode9,UIAlertController中未添加UIExtField 这是我的密码: if ([UIAlertController class]) { UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Forgot Password" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAler
if ([UIAlertController class]) {
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Forgot Password" message:nil preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){[![enter image description here][1]][1]
NSString *str = @"OK Pressed";
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action){
NSString *str = @"otherAction Pressed";
}];
[alert addTextFieldWithConfigurationHandler:^(UITextField *textField) {
textField.placeholder = @"placeHolderText";
textField.keyboardType = UIKeyboardTypeDefault;
}];
[alert addAction:okAction];
[alert addAction:cancelAction];
[self presentViewController:alert animated:YES completion:nil];
}
我刚刚试过你的代码,它工作正常
问题可能在于您调用此代码的位置。例如,它必须在
viewdideappear
中调用,而不是在viewdideload
中调用。可能这个链接可以帮助你好运:)你试过留言吗?是的,我试过用@GökhanAydın,我也试过了。没有解决。你能在哪里使用完整的方法吗?我已经在用户点击上实现了这个操作,除了显示文本字段之外,一切都很好。不要给出评论作为答案。