我正在创建一个每天都会生成不同报价的应用程序。我想让用户能够与推特分享给出的报价。我可以让推特与推文箱一起弹出,但报价没有显示出来。我试图让这样的事情发生,现在,我得到一个恒定的错误:参数#1在调用中失去参数// Twitter
Missing argument for parameter for parameter #1 in call
问题: 我想能够得到的报价,以填补鸣叫箱,因为它的用户后弹出水龙头Twitter的按钮
下面的截图是代码:
@IBAction func shareTweet(sender: AnyObject) {
if SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter) {
Share(text:Quote).shareTwitter().characters.count{ sheet in self.presentViewController(sheet, animated: true, completion: nil)};
let tweetShare:SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
self.presentViewController(tweetShare, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "Accounts", message: "Please login to a Twitter account to tweet.", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil))
self.presentViewController(alert, animated: true, completion: nil)
}
}
这里是share.swift类:
import Social
struct Share {
let text: String
init(text: String) {
self.text = text
}
typealias ShareSheet = SLComposeViewController
func shareTwitter(count: Int, action: (ShareSheet ->()), error: (UIAlertController ->())) { // Returns either tweetSheet or alert view
if (count < 140) {
if (SLComposeViewController.isAvailableForServiceType(SLServiceTypeTwitter)) {
// Tweets Quote
let sheet: SLComposeViewController = SLComposeViewController(forServiceType: SLServiceTypeTwitter)
sheet.setInitialText(text)
action(sheet)
} else {
// Not logged into Twitter
let alert = UIAlertController(title: "Accounts", message: "Please login to a Twitter account to share", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
error(alert)
}
} else {
// Character Count is greater then 140
let alert = UIAlertController(title: "Character Count", message: "Sorry this is too long to tweet", preferredStyle: UIAlertControllerStyle.Alert)
alert.addAction(UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil))
error(alert)
}
}
帮助将不胜感激。先谢谢你。 如果您需要更多参考答案,请评论我应该添加到问题中。谢谢。
对不起,我只是说这在 –
好吧,我想。我明白你现在想要做的全部意图。我的答案已经修改,应该不仅仅是解决你的问题。 – AnthonyM
非常感谢您的解答和解释。错误立即清除。你真棒!保持好状况! –