我想复制这个行为(见下图),并使用这种行动表从我的应用程序分享内容.
问题是:
这真的是一个行动表吗?我找不到iOS 7或8的任何教程.不知道如何继续.
共享选项是否取决于用户的配置?
提示将不胜感激.
解决方法
它不是在UIActionSheet它是UIActivityController是iOS中的默认功能
客观-C
- (void)presentActivityController:(UIActivityViewController *)controller { // for iPad: make the presentation a Popover controller.modalPresentationStyle = UIModalPresentationPopover; [self presentViewController:controller animated:YES completion:nil]; UIPopoverPresentationController *popController = [controller popoverPresentationController]; popController.permittedArrowDirections = UIPopoverArrowDirectionAny; popController.barButtonItem = self.navigationItem.leftBarButtonItem; // access the completion handler controller.completionWithItemsHandler = ^(NSString *activityType,BOOL completed,NSArray *returnedItems,NSError *error){ // react to the completion if (completed) { // user shared an item NSLog(@"We used activity type%@",activityType); } else { // user cancelled NSLog(@"We didn't want to share anything after all."); } if (error) { NSLog(@"An Error occured: %@,%@",error.localizedDescription,error.localizedFailureReason); } }; }
迅速
let shareText = "Hello,world!" if let image = UIImage(named: "myImage") { let vc = UIActivityViewController(activityItems: [shareText,image],applicationActivities: []) presentViewController(vc,animated: true,completion: nil) }
尝试链接的教程
> http://nshipster.com/uiactivityviewcontroller/
> http://www.codingexplorer.com/add-sharing-to-your-app-via-uiactivityviewcontroller/
> http://roadfiresoftware.com/2014/02/how-to-add-facebook-and-twitter-sharing-to-an-ios-app/
迅速