Tuesday, October 1, 2013

UIActionSheet Menu in Xcode

To Show a Menu Sheet like below

We have to code as below

1. First of all, we need to add <UIActionSheetDelegate> delegate in class .h file

2. Now we have to code like below

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Select Image from..." delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"Camera", @"Image Gallary", nil];
actionSheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
actionSheet.tag = 1;
UIWindow* window = [[UIApplication sharedApplication] keyWindow];
if ([window.subviews containsObject:self.view]) {
    [actionSheet showInView:self.view];
} else {
    [actionSheet showInView:window];