Wednesday, 21 March 2012

iPhone Development:Dismiss keyboard while using UITextField inside UIAlertView




UITextField inside UIAlertView Resign KeyBoard

Displaying a text-field inside UIAlertView is a good way to allow user enter a piece of information without letting him to navigate to other screen. The only common problem we faced in this case is hot to dismiss alert when user is done with typing. If alert/pop up has button to dismiss keyboard tehn its fine but if its only text-field no button and user has to dismiss alert/pop up when he press return key of keyboard. For this you have implement textFieldShouldReturn delegate of text-field as it's get called whenever user hit return key of keyboard.

Inside the delegate definition you can make use of dismissWithClickedButtonIndex to get rid of alertview/pop up.


[alertToAddLink dismissWithClickedButtonIndex:
 alertToAddLink.cancelButtonIndex animated:YES]; 




No comments:
Write comments