UIActionSheet事件不会触发
我有一个UIActionSheet在表视图控制器上提供用户选项。 我已经实现了这之前没有问题,但由于某种原因,现在,我的事件处理程序不会触发单击button时。 在我的头文件中,我已经实现了正确的委托,如下所示:
@interface GaugeDetailTableViewController : UITableViewController <UIActionSheetDelegate>
在我的实现中,我有以下代码来支持操作表:
-(void)loadPopup{ UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Options" delegate:nil cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Add to Favorites", @"Gauge Detail Help", @"Main Menu", nil]; popup.actionSheetStyle = UIActionSheetStyleDefault; [popup showInView:self.view]; } -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{ NSLog(@"%d\n", buttonIndex); }
操作表正确显示在视图控制器上,但由于某种原因,操作表单击事件处理程序永远不会到达。 有什么build议么? 谢谢!
您需要设置委托:
UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Options" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Add to Favorites", @"Gauge Detail Help", @"Main Menu", nil]; popup.actionSheetStyle = UIActionSheetStyleDefault;
看起来你忘记了设置委托。 你需要实现UIActionSheetDelegate
(它看起来像你),然后设置委托!