Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/116.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone UIAlertview后数字键盘跳转_Iphone_Ios_Objective C_Xcode_Uialertview - Fatal编程技术网

Iphone UIAlertview后数字键盘跳转

Iphone UIAlertview后数字键盘跳转,iphone,ios,objective-c,xcode,uialertview,Iphone,Ios,Objective C,Xcode,Uialertview,我有一个登录屏幕,当用户多次错误地输入密码时会显示一个警报。单击其中一个按钮时,将显示另一个警报视图,以确认如果我按下第二个警报视图上的取消按钮,数字键盘将从屏幕底部反弹回其原始位置。在第二次警报响应期间,未执行任何代码。有人能帮忙吗 if (loginCount < 5) { // Display alert to user UIAlertView *loginError = [[UIAlertView alloc] initWithTitle:@"Login Failure"

我有一个登录屏幕,当用户多次错误地输入密码时会显示一个警报。单击其中一个按钮时,将显示另一个警报视图,以确认如果我按下第二个警报视图上的取消按钮,数字键盘将从屏幕底部反弹回其原始位置。在第二次警报响应期间,未执行任何代码。有人能帮忙吗

if (loginCount < 5) {
  // Display alert to user
  UIAlertView *loginError = [[UIAlertView alloc] initWithTitle:@"Login Failure" message:@"You have entered an incorrect passcode.  Please try again." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
  [loginError show];

  } else {
    // Display alert to user, including option to reset the app as they have 5 or more login failures
    UIAlertView *loginError = [[UIAlertView alloc] initWithTitle: @"Login Failure" message: @"You have entered an incorrect passcode on 5 or more occasions.  Please try again or reset the app." delegate: self cancelButtonTitle: @"Try Again" otherButtonTitles: @"Reset App", nil]
    [loginError show];
}
// Clear password fields
[self clearPasswordFields];
[passcode1 becomeFirstResponder];
// Increment the login count
loginCount++;

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    // If the user has chosen to reset the app, alert with a confirmation first before resetting
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
    if ([title isEqualToString:@"Reset App"]) {
        // Create alert to give the user the choice to confirm reset
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm Reset" message:@"Are you sure you wish to Reset?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
        [alert show];
    } else if ([title isEqualToString:@"Yes"] && buttonIndex == 1) {
        [Utilities resetApp];
        [self dismissViewControllerAnimated:NO completion:nil];
    }
}
if(loginCount<5){
//向用户显示警报
UIAlertView*loginError=[[UIAlertView alloc]initWithTitle:@“登录失败”消息:@“您输入了错误的密码。请重试。”委托:自取消按钮提示:@“解除”其他按钮提示:无];
[登录错误显示];
}否则{
//向用户显示警报,包括重置应用程序的选项,因为他们有5次或更多登录失败
UIAlertView*loginError=[[UIAlertView alloc]initWithTitle:@“登录失败”消息:@“您在5次或更多情况下输入了错误的密码。请重试或重置应用程序。”代理:自取消按钮:@“重试”其他按钮:@“重置应用程序”,无]
[登录错误显示];
}
//清除密码字段
[自清除密码字段];
[密码1成为第一响应者];
//增加登录计数
loginCount++;
-(无效)alertView:(UIAlertView*)alertView单击按钮索引:(NSInteger)按钮索引{
//如果用户已选择重置应用程序,请在重置前先发出确认警报
NSString*标题=[alertView buttonTitleAtIndex:buttonIndex];
如果([标题isEqualToString:@“重置应用程序”]){
//创建警报,让用户选择确认重置
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@“确认重置”消息:@“是否确实要重置?”代理:自取消按钮:@“否”其他按钮:@“是”,无];
[警报显示];
}else if([title IsequalString:@“Yes”]&&buttonIndex==1){
[应用程序];
[自我解除视图控制器激活:未完成:无];
}
}

我将这样做

在头文件中:

UIAlertView *loginError;
在实现文件中:

-(void)textFieldDidEndEditing:(UITextField *)textField
{
  if (loginCount < 5) {
  // Display alert to user
  loginError = [[UIAlertView alloc] initWithTitle:@"Login Failure" message:@"You have entered an incorrect passcode.  Please try again." delegate:self cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
  [loginError show];

  } else {
    // Display alert to user, including option to reset the app as they have 5 or more login failures
    loginError = [[UIAlertView alloc] initWithTitle: @"Login Failure" message: @"You have entered an incorrect passcode on 5 or more occasions.  Please try again or reset the app." delegate: self cancelButtonTitle: @"Try Again" otherButtonTitles: @"Reset App", nil]
    [loginError show];
}
}

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {

    // If the user has chosen to reset the app, alert with a confirmation first before resetting
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
    if ([title isEqualToString:@"Reset App"]) {
        [self showSecondAlert];
    } else if ([title isEqualToString:@"Yes"] && buttonIndex == 1) {
        [Utilities resetApp];
        [self dismissViewControllerAnimated:NO completion:nil];
    }else{
      [self clearPasswordFields];
      [passcode1 becomeFirstResponder];
    }
}

-(void)showSecondAlert
{
        //make sure you dismiss the old alertview first
         [loginError dismissWithClickedButtonIndex:0  animated:NO];
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Confirm Reset" message:@"Are you sure you wish to Reset?" delegate:self cancelButtonTitle:@"No" otherButtonTitles:@"Yes", nil];
        [alert show];
}
-(void)textfieldDendediting:(UITextField*)textField
{
如果(登录计数<5){
//向用户显示警报
loginError=[[UIAlertView alloc]initWithTitle:@“登录失败”消息:@“您输入了错误的密码。请重试。”委托:自取消按钮:@“解除”其他按钮:无];
[登录错误显示];
}否则{
//向用户显示警报,包括重置应用程序的选项,因为他们有5次或更多登录失败
loginError=[[UIAlertView alloc]initWithTitle:@“登录失败”消息:@“您在5次或更多情况下输入了错误的密码。请重试或重置应用程序。”委托:自取消按钮:@“重试”其他按钮:@“重置应用程序”,无]
[登录错误显示];
}
}
-(无效)alertView:(UIAlertView*)alertView单击按钮索引:(NSInteger)按钮索引{
//如果用户已选择重置应用程序,请在重置前先发出确认警报
NSString*标题=[alertView buttonTitleAtIndex:buttonIndex];
如果([标题isEqualToString:@“重置应用程序”]){
[自我提醒];
}else if([title IsequalString:@“Yes”]&&buttonIndex==1){
[应用程序];
[自我解除视图控制器激活:未完成:无];
}否则{
[自清除密码字段];
[密码1成为第一响应者];
}
}
-(无效)showSecondAlert
{
//确保先关闭旧的alertview
[loginError dismissWithClickedButtonIndex:0动画:否];
UIAlertView*alert=[[UIAlertView alloc]initWithTitle:@“确认重置”消息:@“是否确实要重置?”代理:自取消按钮:@“否”其他按钮:@“是”,无];
[警报显示];
}
希望这有助于