UItextFiled:
新增UITextFieldDelegate
並使alert呼叫出來的textField的delegate = self;
最後在alert的點選事件處新增[[alertView textFieldAtIndex:buttonIndex]resignFirstResponder];
親測可行
-
[程式碼]鍵盤popViewControllerAnimated後再次彈起
//返回到上一介面
-(void)customBackBtnPressed:(id)send{UIAlertView *alertView= [[UIAlertView alloc] initWithTitle:@"溫馨提示" message:@"還差一步就完成註冊! 確定放棄?" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"確定",nil]; [alertView show];
}
//通常用的這個代理方法來做 發現鍵盤在popViewControllerAnimated後會重新出現
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{if (buttonIndex==1) { [self.navigationController popViewControllerAnimated:YES]; }
}
//百思不得其姐後,後了下面這個代理方法,竟然鍵盤不出現了!
-(void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{if (buttonIndex==1) { [self.navigationController popViewControllerAnimated:YES]; }
}