xuzizhou / WeChatActivities-in-iOS-8-with-Swift

MIT License
65 stars 19 forks source link

如何设置UIActivityViewController 里面的image和appURL #8

Open zj2050 opened 9 years ago

zj2050 commented 9 years ago
    let image = UIImage(named: "share.png");
    let appURL = NSURL(string:"tsingbegin7");
    let activityView = UIActivityViewController(
        activityItems: [image!,"WeChat Sharing", appURL!],
        applicationActivities: [WeChatSessionActivity(), WeChatMomentsActivity()])
    self.presentViewController(activityView,
        animated: true,
        completion: nil)

这样设置后执行错误,请问对应的image和URL是什么呢,该如何设置,谢谢

zj2050 commented 9 years ago

NSURL(string:"tsingbegin7"); 其中的 tsingbegin7 是设置的URL Schemes的值 ss-1

zj2050 commented 9 years ago

Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x15fbe620>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.' *\ First throw call stack: (0x251455f7 0x32bf9c77 0x28c8c645 0x288ba785 0x288b9467 0x286671f1 0x285e2eff 0x2510c015 0x251096f9 0x25109afb 0x25056b31 0x25056943 0x2c3de051 0x2864c6f1 0x342ffc 0x33195aaf) libc++abi.dylib: terminating with uncaught exception of type NSException

zj2050 commented 9 years ago

我用模拟器运行了一下,不出现错误,但没有看到微信的图标和内容 no-1

xuzizhou commented 9 years ago

模拟器上不显示是因为模拟器上没有安装微信app URL Schemes里填你的微信app ID

zj2050 commented 9 years ago

谢谢回复,在真机上出现错误,用的是ipad真机

zj2050 commented 9 years ago

Terminating app due to uncaught exception 'NSGenericException', reason: 'UIPopoverPresentationController (<_UIAlertControllerActionSheetRegularPresentationController: 0x15fbe620>) should have a non-nil sourceView or barButtonItem set before the presentation occurs.' *\ First throw call stack: (0x251455f7 0x32bf9c77 0x28c8c645 0x288ba785 0x288b9467 0x286671f1 0x285e2eff 0x2510c015 0x251096f9 0x25109afb 0x25056b31 0x25056943 0x2c3de051 0x2864c6f1 0x342ffc 0x33195aaf) libc++abi.dylib: terminating with uncaught exception of type NSException