首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在SFSafariViewController或Webview中打开推特工具包

如何在SFSafariViewController或Webview中打开推特工具包
EN

Stack Overflow用户
提问于 2017-11-30 19:41:21
回答 0查看 486关注 0票数 0

我正在尝试将twitterKit集成到我的swift项目中。当twitter应用程序安装在我的设备上时,它工作得很好,但如果没有安装twitter应用程序,它会显示消息"No twitter accounts available“,如以下代码所示。如果没有安装twitter应用程序,我想在应用程序中打开一个网页,它将打开twitter登录页面并发布我的推文。这对Facebook工具包来说很好用。任何帮助都将不胜感激。谢谢。

代码语言:javascript
复制
let composer = TWTRComposer()
        composer.setURL(NSURL(string: "https://www.google.com")! as URL)
        if (Twitter.sharedInstance().sessionStore.hasLoggedInUsers()) {
            composer.show(from: self, completion:{ (result) -> Void in
            })
        }
        else {
             Twitter.sharedInstance().logIn(with: self, completion:  { (session, error) in
                if session != nil {
                    composer.show(from: self, completion:{ (result) -> Void in
                    })
                }
                else {
                    let alert = UIAlertController(title: "No Twitter Accounts Available", message: "You must log in before presenting a composer.", preferredStyle: .alert)
                    self.present(alert, animated: false, completion: nil)
                }
            })
        }
EN

回答

页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47572651

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档