如何像 Apple 一样创建带有水平滑块的 UIAlertController 样式 ActionSheet? (图片)

How to create UIAlertControllerStyleActionSheet with horizontal slider as Apple does? (image)

我想在我的应用程序中实现社交分享 - 通过 UIAlertControllerStyleActionSheet

并希望通过水平滑动在一行中添加 Facebook、Twitter、Google+ 等图标 - 与 Apple 的方式相同,例如在分享 Notes 个应用程序。

我还知道如何添加取消按钮)

UIAlertController *alert = [UIAlertController alertControllerWithTitle:nil message:@"Share" preferredStyle:UIAlertControllerStyleActionSheet];
UIAlertAction *cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:nil];
[alert addAction:cancel];
[self presentViewController:alert animated:YES completion:nil];

但不知道如何添加带有图标的水平视图。

你能帮帮我吗?

正如 rmaddy 所述,它是 UIActivityViewController

我的使用示例:

// creating an anchor point for UIActivityViewController than will be used on iPad
CGRect pointRect = [[notification.userInfo objectForKey:@"cellRect"] CGRectValue];
CGRect sourceRect = CGRectMake(pointRect.origin.x, pointRect.origin.y + pointRect.size.height, 5, 5);
UIView *sourceView = [[UIView alloc] initWithFrame:sourceRect];
[self.view addSubview:sourceView];

// prepare object to share
NSString *textToShare = @"Text to share";
NSURL *webSite = [NSURL URLWithString:@"http://website.com"];
NSArray *itemToShare = @[textToShare, webSite];

// initializing custom UIActivity for "Reddit"
RedditActivity *reddit = [[RedditActivity alloc] init];

// initializing popover UIActivityViewController
UIActivityViewController *controller = [[UIActivityViewController alloc]
        initWithActivityItems:itemToShare
        applicationActivities:[NSArray arrayWithObjects:reddit, nil]];

// add anchor point for iPad
if ( [controller respondsToSelector:@selector(popoverPresentationController)] ) {
    controller.popoverPresentationController.sourceView = sourceView;
}

// excluded system UIActivity items
controller.excludedActivityTypes = @[UIActivityTypePostToWeibo,
     UIActivityTypePrint,
     UIActivityTypeAssignToContact,
     UIActivityTypeSaveToCameraRoll,
     UIActivityTypeAddToReadingList,
     UIActivityTypePostToFlickr,
     UIActivityTypePostToVimeo,
     UIActivityTypePostToTencentWeibo,
     UIActivityTypeAirDrop,
     UIActivityTypeOpenInIBooks];

// show popover UIActivityViewController
[self presentViewController:controller animated:YES completion:nil];