Re: [問題] 如何抓UIAlertView裡面某個按鈕的title?
使用 UIAlertView 配合實作 UIAlertViewDelegate 的方式,
其中 alertView:clickedButtonAtIndex: 事件可以取得使用者按下了哪顆按鈕
例如:
- (void)alertView:(UIAlertView *)alertView
clickedButtonAtIndex:(NSInteger)buttonIndex
{
// buttonIndex 就是使用者按下的按鈕索引值
// 取得使用者按下的按鈕標題
NSString *buttonTitle = [alertView buttonTitleAtIndex:buttonIndex];
// 使用者按下了 Cancel 按鈕時
if ([buttonTitle isEqualToString:@"Cancel"]) {
// Do Something
}
// 同上, 但是改用 buttonIndex 來判斷
if (buttonIndex == alertView.cancelButtonIndex) {
// Do Something
}
}
另外補充下面一個我覺得還不錯的 iOS 程式設計中文學習網站,
其中有一篇 UIAlertView 的教學文章剛好符合你的需求
http://furnacedigital.blogspot.com/p/index-search.html
(UIAlertView 判斷使用者按下的按鈕標題)
http://furnacedigital.blogspot.com/2010/12/alerts.html
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.173.29.186
※ 編輯: Phedra 來自: 218.173.29.186 (03/09 13:38)
※ 編輯: Phedra 來自: 218.173.35.177 (04/05 08:38)
討論串 (同標題文章)