UIActionSheet

Posted 大醉和尚

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UIActionSheet相关的知识,希望对你有一定的参考价值。

You need to use a UIActionSheet.

First you need to add UIActionSheetDelegate to your ViewController.h file.

Then you can reference an actionsheet with:

  UIActionSheet *popup = [[UIActionSheet alloc] initWithTitle:@"Select Sharing option:" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:
                        @"Share on Facebook",
                        @"Share on Twitter",
                        @"Share via E-mail",
                        @"Save to Camera Roll",
                        @"Rate this App",
                        nil];
   popup.tag = 1;
  [popup showInView:self.view];

Then you have to handle each of the calls.

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

  switch (popup.tag) {
    case 1: {
        switch (buttonIndex) {
            case 0:
                [self FBShare];
                break;
            case 1:
                [self TwitterShare];
                break;
            case 2:
                [self emailContent];
                break;
            case 3:
                [self saveContent];
                break;
            case 4:
                [self rateAppYes];
                break;
            default:
                break;
        }
        break;
    }
    default:
        break;
 }
}

以上是关于UIActionSheet的主要内容,如果未能解决你的问题,请参考以下文章

在 SWIFT 中处理 UIActionSheet 上的事件

UIActionSheet 只显示一次

iOS:简单使用UIAlertVIew和UIActionSheet

iOS8 上的 UIActionSheet

处理 UIActionSheet

更改 UIActionSheet 中项目的文本颜色 - iOS 8