UIActionSheet 委托方法不会被调用

发布于 2024-11-03 10:17:31 字数 745 浏览 0 评论 0原文

我有一个操作表,似乎只在单击“是”按钮时调用 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,然后将“否”放在另一个按钮上(otherButtonTitles:@“否”,nil)。同样的事情。

有什么帮助吗?
谢谢!

I have an actionsheet that seems to only call the clickedButtonAtIndex delegate method when I click the "Yes" button, but not on the "No" button... Here's the code:

self.myActionSheet = [[UIActionSheet alloc] initWithTitle:@"Test" delegate:self
      cancelButtonTitle:@"No" destructiveButtonTitle:@"Yes" otherButtonTitles:nil];
[self.myActionSheet showInView:self.view];
[myActionSheet release];

then the delegate method:

- (void)actionSheet:(UIActionSheet *)myActionSheet
     clickedButtonAtIndex:(NSInteger)buttonIndex {
    if (buttonIndex == 1) {
        [self.myActionSheet dismissWithClickedButtonIndex:1 animated:YES];
        return;
    }

My breakpoint at the first line of this procedure doesn't get hit unless I touch the
"Yes" button. I have changed this to have the cancelButtonTitle:nil and then put the "No" on another button (otherButtonTitles:@"No", nil). Same thing.

Any help?
Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

﹉夏雨初晴づ 2024-11-10 10:17:31

尝试触摸“否”按钮的最顶部。有效吗?

你有标签栏或工具栏吗?如果是这样,请尝试从选项卡栏或工具栏显示操作表。 “否”按钮可能会被栏部分遮挡。

Try touching the very top of the No button. Does it work?

Do you have a tab bar or a tool bar? If so, try showing the action sheet from the tab bar or the tool bar. The No button could be partially obscured by the bar.

謌踐踏愛綪 2024-11-10 10:17:31

不,这不是一个错误......只是一个“房地产”问题。
从 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;

No, its not a bug.. just a "Real Estate" issue.
take a look at the API.. from the UIActionSheet header...

// 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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文