我什至不知道这是否可行,但我想知道是否可以将 UIView 及其所有内容插入到推文或 Facebook 帖子中,这样当用户从应用程序发送推文时,图像推文中显示了 UIView。任何帮助表示赞赏。这是我的尝试,上面写着//THIS LINE DOES NOT DO ANYTHING:
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.")
}
}
}
最佳答案
您可以将 View 捕获到 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
}
关于ios - 如何在社交媒体帖子中显示 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30633459/