Why doesn't dismissWithClickedButtonIndex ever call clickedButtonAtIndex?

前端 未结 4 1298
梦谈多话
梦谈多话 2021-01-04 08:35

http://iphonedevelopment.blogspot.com/2009/02/alert-view-with-prompt.html

I\'m using that code to get my iPhone app to display an alertView with an included UITextFi

4条回答
  •  悲哀的现实
    2021-01-04 09:09

    I'm not sure whether I fully understand your question, but here is my try:

    Firstly, you need to remove the if (buttonIndex != [alertView cancelButtonIndex]) from the example. This should work for the OK and CANCEL buttons.

    To recognize the DONE key of the keyboard, use - (BOOL)textFieldShouldReturn:(UITextField *)textField of the UITextFieldDelegate. Here you could call [textField resignFirstResponder] to dismiss the keyboard.

    Also, what to you do in clickedButtonAtIndex? Couldn't you create your own method and the call it when you need it?

提交回复
热议问题