Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad UIActionSheet - Not displaying the last added button

I'm trying to display a UIActionSheet from my iPad. Here's the code that I'm using:

-(void) presentMenu {
    UIActionSheet *popupMenu = [[UIActionSheet alloc] initWithTitle:@"Menu" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:nil];
    for (NSString *option in _menuItems) {
        [popupMenu addButtonWithTitle:option];
    }
    popupMenu.actionSheetStyle = UIActionSheetStyleBlackOpaque;
    if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
        [popupMenu showFromTabBar:_appDelegate.tabBar.tabBar];
    }
    else if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
        [popupMenu showFromBarButtonItem:self.navigationItem.rightBarButtonItem animated:YES];
    }
    [popupMenu release];
    return;
}

The iPhone version of the program displays all the buttons in _menuItems, but the iPad version just ignores the last item from that array. Does anyone know why this might be happening?

Thanks,
Teja.

like image 249
Tejaswi Yerukalapudi Avatar asked Oct 06 '11 18:10

Tejaswi Yerukalapudi


1 Answers

Found the answer as soon as I typed out this post. Somehow removing the "Cancel" button causes both the buttons to come up. Weird.

EDIT: Although, this is really annoying because all my button indices change between the iPhone and the iPad versions (The iPhone still needs the cancel button). How do I handle this?

like image 131
Tejaswi Yerukalapudi Avatar answered Oct 03 '22 10:10

Tejaswi Yerukalapudi