我有一个 UIActionSheet 来在表视图控制器上提供用户选项。我之前已经实现了这一点,没有出现任何问题,但现在由于某种原因,单击按钮时我的事件处理程序不会触发。在我的头文件中,我已经实现了正确的委托,如下所示:
@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);
}
操作表正确显示在视图控制器上,但由于某种原因,永远无法到达操作表单击事件处理程序。有什么建议么?谢谢!
您需要设置委托:
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;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)