노블의 개발이야기

[iOS] UIActionSheet 본문

iOS

[iOS] UIActionSheet

더플러스 2015. 7. 13. 12:02

UIActionSheet


UIActionSheet is deprecated in iOS 8.

(Note that UIActionSheetDelegate is also deprecated.)

To create and manage action sheets in iOS 8 and later, instead use UIAlertController with a preferredStyle of UIAlertControllerStyleActionSheet.




- (IBAction)showActionSheet:(id)sender {

    UIActionSheet *actionSheet =

    [[UIActionSheet alloc] initWithTitle:@"Select the operation to proceed?"

                                delegate:self cancelButtonTitle:@"Cancel"

                  destructiveButtonTitle:@"Delete"

                       otherButtonTitles:@"Create", @"Update", @"Duplicate", nil];

    [actionSheet showInView:self.view];

}


<Delegate>

#pragma mark - UIActionSheetDelegate

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {

    

    if (buttonIndex == [actionSheet cancelButtonIndex]) {

        NSLog(@"ActionSheet : Cancel Button Clicked");

        return;

    }

    else if (buttonIndex == [actionSheet destructiveButtonIndex]) {

        NSLog(@"ActionSheet(%ld) : Delete Button Clicked", buttonIndex);

        

    }

    else if (buttonIndex == [actionSheet firstOtherButtonIndex]) {

        NSLog(@"ActionSheet(%ld) : Create Button Clicked", buttonIndex);

    }

    else if (buttonIndex == [actionSheet firstOtherButtonIndex] + 1) {

        NSLog(@"ActionSheet(%ld) : Update Button Clicked", buttonIndex);

    }

    else {

        NSLog(@"ActionSheet(%ld) : Duplicate Button Clicked", buttonIndex);

    }

    

}



UIActionSheetSample.zip



Comments