UIActionSheet事件未触发 [英] UIActionSheet event not firing

查看:85
本文介绍了UIActionSheet事件未触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个UIActionSheet,可以在表视图控制器上提供用户选项.我之前已经实现了这一点,没有问题,但是由于某些原因,当单击按钮时,我的事件处理程序不会触发.在我的头文件中,我实现了以下适当的委托:

I have a UIActionSheet to provide user options on a table view controller. I have implemented this before without issue, but for some reason now, my event handler does not fire when a button is clicked. In my header file, I have implemented the proper delegate as follows:

@interface GaugeDetailTableViewController : UITableViewController <UIActionSheetDelegate>

在我的实现中,我具有以下代码来支持操作表:

In my implementation, I have the following code to support the action sheet:

-(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);
}

操作表会正确显示在视图控制器上,但是由于某些原因,操作表单击事件处理程序永远不会到达.有什么建议?谢谢!

The action sheet appears properly on the view controller, but for some reason, the action sheet click event handler is never reached. Any suggestions? Thanks!

推荐答案

您需要设置委托:

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;

这篇关于UIActionSheet事件未触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆