【问题标题】:UIActionSheet delegate method doesn't get calledUIActionSheet 委托方法没有被调用
【发布时间】:2011-04-27 20:33:22
【问题描述】:

我有一个操作表,似乎只在我单击“是”按钮时调用 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)。一样的。

有什么帮助吗?
谢谢!

【问题讨论】:

    标签: iphone ios uiactionsheet


    【解决方案1】:

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

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

    【讨论】:

    • 天哪,你真是个天才特里....是的,我确实有一个标签栏。这是一个错误吗?关于如何解决这个问题的任何建议?
    • 使用 showFromTabBar。这会将工作表放在正确的位置以获得所有触摸。
    • 我总是犯同样的错误 :)
    • 我已经做了很多次了。这就是为什么我知道要问哪些问题。
    【解决方案2】:

    不,这不是错误……只是“房地产”问题。 看看 API.. 从 UIActionSheet 标头...

    // 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;
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-12-03
      • 2020-11-28
      • 2017-05-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多