在iPhone中禁用共享表中的“更多”按钮

时间:2016-04-01 18:46:56

标签: ios iphone swift uiactionsheet sharekit

我想禁用共享表中的“更多”按钮。

请检查此图片:

enter image description here

可以通行吗? 任何人都可以帮助我吗?

我的代码如下:

let objectsToShare:NSArray = [firstActivityItem]
    let vc = UIActivityViewController(activityItems: objectsToShare as [AnyObject], applicationActivities: nil)


    vc.excludedActivityTypes=[UIActivityTypePostToWeibo,
        UIActivityTypePrint,
        UIActivityTypeCopyToPasteboard,
        UIActivityTypeSaveToCameraRoll,
        UIActivityTypeAddToReadingList,
        UIActivityTypePostToFlickr,
        UIActivityTypePostToVimeo,
        UIActivityTypePostToTencentWeibo,
        UIActivityTypeAirDrop,UIActivityTypeAssignToContact,"com.apple.reminders.RemindersEditorExtension","com.apple.mobilenotes.SharingExtension"]

myviewcontroller.presentViewController(vc, animated: true, completion: nil)

我只想要邮件,短信,Facebook和Twitter。是否可以以编程方式进行自定义。

1 个答案:

答案 0 :(得分:1)

如果您有共享应用程序列表超过4个项目,如果我理解正确的话,将会自动显示更多内容。

所以我建议让我们点击更多内容,查看所有应用程序列表的内容,然后你应该排除那些你不会在这里,

let objectsToShare:NSArray = [firstActivityItem]
let vc = UIActivityViewController(activityItems: objectsToShare as [AnyObject], applicationActivities: nil)

vc.excludedActivityTypes =
       [UIActivityTypePostToWeibo,
        UIActivityTypePrint,
        UIActivityTypeCopyToPasteboard,
        UIActivityTypeSaveToCameraRoll,
        UIActivityTypeAddToReadingList,
        UIActivityTypeAssignToContact,
        UIActivityTypePrint,
        UIActivityTypeMessage,
        UIActivityTypeMail,
        UIActivityTypeAirDrop,
        UIActivityTypePostToFlickr,
        UIActivityTypePostToVimeo,
        UIActivityTypePostToTencentWeibo,
        UIActivityTypeAirDrop,
        UIActivityTypeAssignToContact,
"com.apple.reminders.RemindersEditorExtension","com.apple.mobilenotes.SharingExtension"]

myviewcontroller.presentViewController(vc, animated: true, completion: nil)

Reference