0
Я использую OAuthSwift, он отлично работает, но когда я нажимаю на кнопку входа в систему, он открывает новую страницу Safari. Я хотел бы открыть URL-адрес в приложении, но я начинаю, и я не знаю, как это сделать.Swift: как открыть URL-адрес в приложении
Мой код:
@IBAction func loginButton(sender: AnyObject) {
doOAuthDribbble()
}
func doOAuthDribbble(){
let oauthswift = OAuth2Swift(
consumerKey: Dribbble["consumerKey"]!,
consumerSecret: Dribbble["consumerSecret"]!,
authorizeUrl: "https://dribbble.com/oauth/authorize",
accessTokenUrl: "https://dribbble.com/oauth/token",
responseType: "code"
)
oauthswift.authorizeWithCallbackURL(NSURL(string: "dribs://oauth-callback/dribbble")!, scope: "public+write+comment+upload", state: "", success: {
credential, response in
// Get User
var parameters = Dictionary<String, AnyObject>()
oauthswift.client.get("https://api.dribbble.com/v1/user?access_token=\(credential.oauth_token)", parameters: parameters,
success: {
data, response in
let jsonDict: AnyObject! = NSJSONSerialization.JSONObjectWithData(data, options: nil, error: nil)
println(jsonDict)
}, failure: {(error:NSError!) -> Void in
println(error)
})
}, failure: {(error:NSError!) -> Void in
println(error.localizedDescription)
})
}
Моя страница Войти
то новое сафари страница
Используйте UIWebView – Arbitur
Это [SO вопрос] (http://stackoverflow.com/questions/8310109/create -a-uiwebview-and-load-a-website-programically) решает вашу проблему. Это Objective-C, но его можно легко перевести в Swift –