【发布时间】:2018-03-13 12:10:25
【问题描述】:
预期行为:
用户在TextField1 内部点击,键盘弹出,用户输入一个值,NextButton 被按下,键盘应该被关闭。
异常:键盘在按下NextButton 时被解除,但是在随后的警报被解除后它再次弹出!为什么?
另一方面,如果从未调用过警报 (//[self showDisclaimer]),则键盘会正确关闭...
我知道alertView 已被弃用,但这不是错误的根源,因为如果我改用UIAlertController,我会得到完全相同的行为。
有人可以解释一下吗?
- (IBAction) NextButton: (id) sender
{
[self backgroundTouch:id]; //Dismisses the keyboard
[self showDisclaimer];
}
- (void) showDisclaimer {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Disclaimer" message: @"bla bla bla"
delegate:self
cancelButtonTitle: nil
otherButtonTitles:@"Don't agree", @"I AGREE", nil];
[alertView show];
}
- (void)alertView:(UIAlertView *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
if([title isEqualToString:@"I AGREE"])
{
[self showAlert];
}
else if([title isEqualToString:@"Don't agree"])
{
//Do something else
}
}
- (IBAction) backgroundTouch: (id)sender {
[TextField1 resignFirstResponder];
}
【问题讨论】:
-
jeddi 遵循以下答案
标签: ios objective-c keyboard uialertview uialertviewcontroller