我的项目中有以下几行代码…… @IBAction func shareMeme(sender: UIBarButtonItem) { let newMeme = save() let memedImage = newMeme.memedImage let activityViewController = UIActivityViewController(activityItems: [memedImage], appli
@IBAction func shareMeme(sender: UIBarButtonItem) { let newMeme = save() let memedImage = newMeme.memedImage let activityViewController = UIActivityViewController(activityItems: [memedImage], applicationActivities: nil) presentViewController(activityViewController, animated: true, completion: nil) activityViewController.completionWithItemsHandler = {(type: String!, completed: Bool, returnedItems: [AnyObject]!, error: NSError!) -> Void in dispatch_async(dispatch_get_main_queue()){ self.presentingViewController?.dismissViewControllerAnimated(true, completion: nil) } } }
我不断收到编译器错误“无法分配类型的值'(String!,Bool,[AnyObject]!,NSError!) – > Void’到’UIActivityViewControllerCompletionWithItemsHandler?’”类型的值,引用下面的代码行…
activityViewController.completionWithItemsHandler = {(type: String!, completed: Bool, returnedItems: [AnyObject]!, error: NSError!) -> Void in
任何建议,将不胜感激.
你的类型签名与UIActivityViewControllerCompletionWithItemsHandler的定义不匹配,它是(String?,Bool,[AnyObject] ?, NSError?) – >虚空.用?s替换你的!它应该可以正常工作.