开发者

UIActionSheet delegate method doesn't get called

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 dismissWithClickedB开发者_运维技巧uttonIndex: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!


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.


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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜