ShareButton
函数在Xcode 6中工作正常,但在升级到Xcode 7
后,该行中出现错误:
具有项目处理程序的平均完成时间= {
我的代码:
@IBAction func ShareButton(sender: AnyObject) {
let things = ["Thank you"]
let avc = UIActivityViewController(activityItems:things, applicationActivities:nil)
avc.setValue("Salon Job HK", forKey: "subject")
avc.completionWithItemsHandler = {
(s: String!, ok: Bool, items: [AnyObject]!, err:NSError!) -> Void in
}
self.presentViewController(avc, animated:true, completion:nil)
if let pop = avc.popoverPresentationController {
let v = sender as! UIView // sender would be the button view tapped, but could be any view
pop.sourceView = v
pop.sourceRect = v.bounds
}
}
3条答案
按热度按时间fykwrbwg1#
只需检查Swift 2.0用户界面活动视图控制器的CompletionWithItemsHandler声明:
类型别名UIActivityViewControllerCompletionWithItemsHandler =(字符串?,布尔值,[任意对象]?,NSError?)-〉无效
请这样尝试:
或者简单地说:
雨燕3
w46czmvw2#
这在Swift 3.0中再次发生了轻微变化:
uurv41yg3#
除了上面的答案之外,您还可以将其设置为nil,因为在调用完成时您似乎没有执行任何操作