我甚至不知道这是否可行,但我想知道是否有任何方式你可以将UIView及其所有内容插入推文或facebook帖子中,这样当用户从应用程序发出推文时,图像UIView的内容显示在推文中。任何帮助表示赞赏。这是我的尝试,它说//这条线没有做任何事情:
func sendSocialPost(serviceType:String) {
if SLComposeViewController.isAvailableForServiceType(serviceType) {
// Users device is good for Twitter
let socialDialog:SLComposeViewController = SLComposeViewController(forServiceType: serviceType)
socialDialog.setInitialText("Whats the mood like?")
// THIS LINE DOES NOT DO ANYTHING
socialDialog.inputAccessoryView?.insertSubview(self.scrollViewView, aboveSubview: self.contentView)
socialDialog.completionHandler = { (result:SLComposeViewControllerResult) in
// Check if the user sent the tweet of cancelled it
if result == SLComposeViewControllerResult.Done {
// User has sent social post
NSLog("post sent")
}
else if result == SLComposeViewControllerResult.Cancelled {
NSLog("post cancelled")
}
}
// Present the social dialog box
self.presentViewController(socialDialog, animated: true, completion: nil)
}
else {
// Social Account credentials haven't been added to the settings
if serviceType == SLServiceTypeTwitter {
NSLog("A Twitter account needs to be set up in the Settings app.")
}
else if serviceType == SLServiceTypeFacebook {
NSLog("A Facebook account needs to be set up in the Settings app.")
}
}
}
答案 0 :(得分:1)
您可以捕获UIImage的视图并发推文...... 如果这就是你的意思..
func captureViewArea() -> UIImage {
UIGraphicsBeginImageContextWithOptions(self.viewToCapture.bounds.size, self.viewToCapture.opaque, 0.0)
self.viewToCapture.layer.renderInContext(UIGraphicsGetCurrentContext())
let viewImage = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return viewImage
}