我正在創建一個每天都會生成不同報價的應用程序。我想讓用戶能夠與推特分享給出的報價。我可以讓推特與推文箱一起彈出,但報價沒有顯示出來。我試圖讓這樣的事情發生,現在,我得到一個恆定的錯誤:參數#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
非常感謝您的解答和解釋。錯誤立即清除。你真棒!保持好狀況! –