我实施了Twitter分享按钮,但没有专栏来更改Twitter图片这样的图片。如果我从帐户退出,我无法授权(登录)其他帐户。授权视图永远不会出现。
我的应用没有2列("帐号"和"位置")。所以我不能改变帐户,除非我最初授权。 我该如何解决这个问题?
(如果可能的话,在我授权和推文一次后从所有帐户退出时,能够授权帐户会更好。但我不知道该怎么做....)
let shareImage = UIImage(named:"Twitter_shareImage")
let tweetDescription:String = "text"
TWTRTwitter.sharedInstance().sessionStore.saveSessionWithAuthToken(authToken, authTokenSecret: authTokenSecret, completion: { (session, error) -> Void in
if (TWTRTwitter.sharedInstance().sessionStore.hasLoggedInUsers()) {
if let session = TWTRTwitter.sharedInstance().sessionStore.session() {
let composer = TWTRComposer()
composer.setText("text")
composer.setImage(shareImage)
composer.show(from: self.parentViewController()!, completion: nil)
print(session.userID)
} else {
TWTRTwitter.sharedInstance().logIn {
(session, error) -> Void in
if (session != nil) {
// println("signed in as \(session.userName)");
} else {
// println("error: \(error.localizedDescription)");
}
}
print("no account")
}
} else {
// Log in, and then check again
TWTRTwitter.sharedInstance().logIn { session, error in
if session != nil { // Log in succeeded
let composer = TWTRComposer()
composer.setText("text")
composer.setImage(shareImage)
composer.show(from: self.parentViewController()!, completion: nil)
} else {
let alert = UIAlertController(title: "No Twitter Accounts Available", message: "You must log in before presenting a composer.", preferredStyle: .alert)
self.parentViewController()?.present(alert, animated: false, completion: nil)
}
}
}