我的项目完全在故事板中,我在UITableViewController
中嵌入了NavigationController
,在每个单元格中我都有一个按钮来分享通知。
@IBAction func shareSheetButtonFeed(sender: AnyObject) {
let btnPos: CGPoint = sender.convertPoint(CGPointZero, toView: self.tableView)
let indexPath: NSIndexPath = self.tableView.indexPathForRowAtPoint(btnPos)!
passaValor = Int(indexPath.row)
let printtestess = (objects?[passaValor] as! PFObject)
let textToShare: AnyObject = (printtestess.objectForKey("subject")! as! String) + " - Cheque agora em:"
let myWebsite = NSURL(string:"http://www.mysite.com.br/")
let img: UIImage = UIImage(named: "myLogo-1024x1024")!
guard let url = myWebsite else {
print("nothing found")
return
}
self.navigationController?.setNavigationBarHidden(false, animated: true)
let shareItems:Array = [img, textToShare, url]
let activityViewController:UIActivityViewController = UIActivityViewController(activityItems: shareItems, applicationActivities: nil)
activityViewController.excludedActivityTypes = [UIActivityTypePrint, UIActivityTypePostToWeibo, UIActivityTypeCopyToPasteboard, UIActivityTypeAddToReadingList, UIActivityTypePostToVimeo]
self.presentViewController(activityViewController, animated: true, completion: nil)
}
问题是,当我点击按钮时会显示shareSheet,在我选择社交网络之后,比如Twitter或Facebook,我以前的NavigationBar消失。
我尝试使用此行在按钮内解决问题,当我再次单击按钮时,navBar重新出现:
self.navigationController?.setNavigationBarHidden(false, animated: true)
所以我试着把这一行放在ViewWillAppear
里面,但它不起作用。
Obs:我使用自动布局
感谢。
答案 0 :(得分:1)
请等待共享表关闭以显示导航栏。为此,请在UIActivityViewController上设置completionWithItemsHandler
属性。
activityViewController.completionWithItemsHandler = { _ in
self.navigationController?.setNavigationBarHidden(false, animated: true)
}