2010-10-04 151 views
37

有沒有辦法以編程方式隱藏UIAlertView?實際上,我在UIAlertView中添加了一個UITextField,並且當用戶敲擊鍵盤返回鍵時,我想要執行與「Ok」按鈕按下相同的操作。以編程方式隱藏UIAlertView?

回答

81

呼叫

[theAlertView dismissWithClickedButtonIndex:0 animated:YES]; 
當你處理返回鍵

+1

謝謝你。如果你想讓它更靈活一些,你也可以說'[theAlertView dismissWithClickedButtonIndex:theAlertView.cancelButtonIndex animated:YES];''或'[theAlertView dismissWithClickedButtonIndex:theAlertView.firstOtherButtonIndex animated:YES];'點擊第一個不取消按鈕。 – palme 2013-11-22 09:40:33

相關問題