Ipad – How to show an action sheet inside the popover

actioncontrolleripadpopover

I have a split View controller, in which the left side holds a table view controller. How do I show an action sheet inside the popover when I click on the detail disclosure button of the table cell?

Best Answer

Try this :

UIActionSheet *popupSheet = [[UIActionSheet alloc] initWithTitle:@"Title" 
                                                        delegate:self 
                                               cancelButtonTitle:@"Cancel" 
                                          destructiveButtonTitle:@"No Way !" 
                                               otherButtonTitles:nil];

popupSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;
UIButton * disclosureButton = (UIButton *)cell.accessoryView;

[popupSheet showFromRect:disclosureButton.bounds inView:cell.accessoryView animated:YES];
[popupSheet release];

The UIActionSheet docs state that the showFromRect:inView:animated: method:

displays the action sheet in a popover whose arrow points to the specified rectangle of the view (in our case the detail disclosure button). The popover does not overlap the specified rectangle.