Last active
December 31, 2015 10:45
-
-
Save g-1/4f16031040b93e3d2a4b to your computer and use it in GitHub Desktop.
FabricでTwitterのタイムラインを表示する(サンプル版) ref: http://qiita.com/g-1/items/43ecf43dd997af9f99bb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import TwitterKit | |
class LoginViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let logInButton = TWTRLogInButton { (session, error) in | |
if session != nil { | |
self.performSegueWithIdentifier("main", sender: session!.userName) | |
} else { | |
NSLog("Login error: %@", error!.localizedDescription); | |
} | |
} | |
// TODO: Change where the log in button is positioned in your view | |
logInButton.center = self.view.center | |
self.view.addSubview(logInButton) | |
} | |
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { | |
let session = sender as? TWTRSession | |
let dest = segue.destinationViewController as! MainViewController | |
dest.title = session!.userName | |
dest.userId = session?.userID | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
import TwitterKit | |
class MainViewController: TWTRTimelineViewController { | |
var userId: String? | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
let client = TWTRAPIClient(userID: self.userId) | |
self.dataSource = TWTRUserTimelineDataSource(screenName: "fabric", APIClient: client) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment