所以,我很难过......这是图片供快速参考:http://i.imgur.com/zM1VJdi.png
问题是当textField被添加到UIAlertController时,文本字段的高度大于一行,并且位于UIAlertController按钮下面。有关为什么会发生这种情况的任何想法?
以下是代码:
UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title"
message:@"Message"
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Cancel"
style:UIAlertActionStyleCancel
handler:nil];
UIAlertAction *resetDataAction = [UIAlertAction actionWithTitle:@"Delete"
style:UIAlertActionStyleDestructive
handler:^(UIAlertAction *action) {
// handler code
}];
[alertController addAction:resetDataAction];
[alertController addAction:cancelAction];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
//handler code
}];
[self presentViewController:alertController animated:YES completion:nil];
答案 0 :(得分:0)
因为您添加了按钮,然后是文本字段。
[alertController addAction:resetDataAction];
[alertController addAction:cancelAction];
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
//handler code
}];
但你需要这样做
[alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) {
//handler code
}];
[alertController addAction:resetDataAction];
[alertController addAction:cancelAction];