自Xcode 9与Swift 4和IOS一起编写Twitterkit中的推文11
问题描述:
自从升级到Xcode 9和Swift 4以来,我一直忙于让应用程序重新开始工作。但我还在努力让我的推文作曲家工作。在Xcode中8这仍然工作正常...自Xcode 9与Swift 4和IOS一起编写Twitterkit中的推文11
case "Twitter":
if (Twitter.sharedInstance().sessionStore.hasLoggedInUsers()) {
// App must have at least one logged-in user to compose a Tweet
let composer = TWTRComposerViewController.emptyComposer()
UIApplication.shared.keyWindow?.rootViewController?.present(composer, animated: true, completion: nil)
} else {
// Log in, and then check again
Twitter.sharedInstance().logIn { session, error in
if session != nil { // Log in succeeded
let composer = TWTRComposerViewController.emptyComposer()
UIApplication.shared.keyWindow?.rootViewController?.present(composer, animated: true, completion: nil)
} else {
let alert = UIAlertController(title: "No Twitter Accounts Available", message: "You must log in before presenting a composer.", preferredStyle: .alert)
UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: false, completion: nil)
}
}
}
就是我现在litterly复制从Twitter的工具包网站粘贴和调整,因为我有我的共享功能都在一个单独的类。
当这段代码开始时,我的Twitter应用程序被打开,authenticatin屏幕被打开,我有种期待: Authenticating
当我连接,它很快就表明了我的时间线,和不只是回到我的应用程序。没有撰写窗口...
任何想法?
答
问题的在AppDelegate中添加此解决:
func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let handled:Bool = true
Twitter.sharedInstance().application(app, open: url, options: options)
return handled
}