UIAlertController添加输入框问题?

qq_32270687 2016-09-14 02:30:16
ViewController * vc = (id)self.parentViewController;
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"Create Wishlist" message:@"" preferredStyle:UIAlertControllerStyleAlert];
// 创建文本框
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField){
textField.placeholder = @"登录";
}];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleCancel handler:nil];

UIAlertAction *createAction = [UIAlertAction actionWithTitle:@"Create" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {

//读取收入框的内容的方法
UITextField *login = alertController.textFields.firstObject;

}];

[alertController addAction:cancelAction];
[alertController addAction:createAction];

[vc presentViewController:alertController animated:YES completion:nil];

为什么对话框弹出来,不显示输入框??控制台报一堆的debugger
The relevant UICollectionViewFlowLayout instance is <_UIAlertControllerCollectionViewFlowLayout: 0x7ff4630e4000>, and it is attached to <UICollectionView: 0x7ff461828600; frame = (0 104.667; 270 44); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x7ff4630e4cd0>; layer = <CALayer: 0x7ff4630e4640>; contentOffset: {0, 0}; contentSize: {0, 0}> collection view layout: <_UIAlertControllerCollectionViewFlowLayout: 0x7ff4630e4000>

这是什么情况??

...全文
487 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
看_灰机 2016-09-14
  • 打赏
  • 举报
回复
http://blog.csdn.net/w582324909/article/details/52539421
看_灰机 2016-09-14
  • 打赏
  • 举报
回复
UIAlertView *alertView//创建alertView,title什么的自己写; [alertView setAlertViewStyle:UIAlertViewStylePlainTextInput]; //style,带文本框的 UITextField *evaluate = [alertView textFieldAtIndex:0]; //evaluate 就是文本框了,可以获取里面输入的内容,也可设置属性。

29,031

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧