我有一个动作表,当我单击“是”按钮时,似乎只调用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)。同样的事情。
任何帮助?
谢谢!
答案 0 :(得分:5)
尝试触摸否按钮的顶部。它有效吗?
您是否有标签栏或工具栏?如果是这样,请尝试从标签栏或工具栏中显示操作表。条形图可以部分遮挡“否”按钮。
答案 1 :(得分:1)
不,它不是一个错误..只是一个“房地产”问题。 从UIActionSheet标题看看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;