如何在单击“取消”按钮时关闭UIActivityViewController?

时间:2016-09-22 11:13:08

标签: ios swift

    let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil)
    let excludeActivities = [UIActivityTypeAirDrop, UIActivityTypePrint, UIActivityTypeAssignToContact, UIActivityTypeSaveToCameraRoll, UIActivityTypeAddToReadingList, UIActivityTypePostToFlickr, UIActivityTypePostToVimeo,UIActivityTypeMail,UIActivityTypeOpenInIBooks,UIActivityTypeCopyToPasteboard]

    activityVC.excludedActivityTypes=excludeActivities
    let nav = UINavigationController(rootViewController: activityVC)
    nav.modalPresentationStyle = UIModalPresentationStyle.Popover
    let popover = nav.popoverPresentationController as UIPopoverPresentationController!
    activityVC.preferredContentSize = CGSizeMake(0,150)
    popover.sourceView = self.view
    popover.sourceRect = CGRectMake(345,580,0,0)
    self.presentViewController(nav, animated: true, completion: nil)

我正在尝试在单击取消按钮时关闭活动控制器,但这不起作用。 单击控制器外部的任何位置时,将被取消,但不会通过点击取消按钮。

1 个答案:

答案 0 :(得分:0)

请使用此

.foo