2015-10-27 78 views

回答

0

試試這個代碼,希望它會有助於您:

import UIKit 
import SafariServices 

class ViewController: UIViewController, SFSafariViewControllerDelegate { 
    override func viewDidLoad() { 
     super.viewDidLoad() 

     let myActivity = NSUserActivity(activityType: "com.google.searchAPIs.detail") 
     myActivity.title = "Cupertino" // 2 
     myActivity.eligibleForSearch = true // 4 
     myActivity.keywords = Set(arrayLiteral: "Cupertino", "Silcon Valley", "California", "San Jose", "San Francisco", "Apple Inc", "Mothership") // 5 
     self.userActivity = myActivity // 6 
     myActivity.eligibleForHandoff = false // 7 
     myActivity.becomeCurrent() // 8 



     // Do any additional setup after loading the view, typically from a nib. 
    } 

    @IBAction func didPressButton(sender: AnyObject) { 

     let safariVC = SFSafariViewController(URL:NSURL(string: "https://en.wikipedia.org/wiki/Cupertino,_California")!, entersReaderIfAvailable: true) // Set to false if not interested in using reader 
     safariVC.delegate = self 
     self.presentViewController(safariVC, animated: true, completion: nil) 
    } 

    func safariViewControllerDidFinish(controller: SFSafariViewController) { 

     controller.dismissViewControllerAnimated(true, completion: nil) 
    } 

    override func didReceiveMemoryWarning() { 
     super.didReceiveMemoryWarning() 
     // Dispose of any resources that can be recreated. 
    } 


} 
+0

嗨王子,我使用fitbit登錄的API,我需要登錄後取得網址。 我在目標c中使用代碼。請幫助我客觀c –

+0

請檢查此鏈接:https://auth0.com/authenticate/ios-swift/fitbit –

+0

檢查此鏈接希望這可能會幫助你:https://omarmetwally.quora.com/Integrating-在-Fitbit-API功能於IOS的應用 –