【发布时间】:2017-10-25 07:43:37
【问题描述】:
UITextfield 没有被添加到 UIAlertController 中
这是我的代码:
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];
}
【问题讨论】:
-
也许这个链接可以帮助你stackoverflow.com/questions/33996443/…Goodluck :)
-
您尝试过留言吗?
-
是的,我用@""试过了
-
@GökhanAydın 我也试过了。没有成功。
-
你可以分享你使用的完整方法吗?
标签: objective-c iphone xcode9