[英]UIActionSheet delegate method doesn't get called
我有一個動作表,似乎只在我單擊“是”按鈕時調用 clickedButtonAtIndex 委托方法,而不是在“否”按鈕上......這是代碼:
self.myActionSheet = [[UIActionSheet alloc] initWithTitle:@"Test" delegate:self
cancelButtonTitle:@"No" destructiveButtonTitle:@"Yes" otherButtonTitles:nil];
[self.myActionSheet showInView:self.view];
[myActionSheet release];
然后委托方法:
- (void)actionSheet:(UIActionSheet *)myActionSheet
clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 1) {
[self.myActionSheet dismissWithClickedButtonIndex:1 animated:YES];
return;
}
除非我點擊“是”按鈕,否則我在此過程第一行的斷點不會被擊中。 我已將其更改為具有cancelButtonTitle:nil,然后將“No”放在另一個按鈕上(otherButtonTitles:@“No”,nil)。 一樣。
有什么幫助嗎?
謝謝!
嘗試觸摸“否”按鈕的最頂部。 它有效嗎?
你有標簽欄或工具欄嗎? 如果是這樣,請嘗試從選項卡欄或工具欄顯示操作表。 否按鈕可能會被欄部分遮擋。
不,它不是一個錯誤.. 只是一個“房地產”問題。 看看來自 UIActionSheet header 的 API ..
// show a sheet animated. you can specify either a toolbar, a tab bar, a bar butto item or a plain view. We do a special animation if the sheet rises from
// a toolbar, tab bar or bar button item and we will automatically select the correct style based on the bar style. if not from a bar, we use
// UIActionSheetStyleDefault if automatic style set
- (void)showFromToolbar:(UIToolbar *)view;
- (void)showFromTabBar:(UITabBar *)view;
- (void)showFromBarButtonItem:(UIBarButtonItem *)item animated:(BOOL)animated __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_2);
- (void)showFromRect:(CGRect)rect inView:(UIView *)view animated:(BOOL)animated __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_2);
- (void)showInView:(UIView *)view;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.