Can I customize the Twitter login button on iOS?

I downloaded the Twitter framework and added the code to enter Twitter. But I do not want the login button to look like this. I want to create a custom login button. I can do it? I just want to use this infrastructure as it also uses the iOS system account.

Please provide me with solutions or suggestions.

Thanks in advance!

+6
source share
3 answers

In accordance with :

Add the code to your button:

Objective-c

[[Twitter sharedInstance] logInWithCompletion:^ (TWTRSession *session, NSError *error) { if (session) { NSLog(@"signed in as %@", [session userName]); } else { NSLog(@"error: %@", [error localizedDescription]); } }]; 

Swift

 Twitter.sharedInstance().logInWithCompletion { (session, error) -> Void in if (session != nil) { println("signed in as \(session.userName)"); } else { println("error: \(error.localizedDescription)"); } } 
+21
source

Yes, you can customize your Twitter login button.

Just add your UIButton to your storyboard screen. Select it and open the Identity Inspector, now in the Class text box, enter TWTRLogInButton, and then create a property.

You will create something like this: -

 @property (nonatomic,strong) IBOutlet TWTRLogInButton *customTwitterButton; 

After that, you can use it or implement it in your viewDidLoad method as follows: -

 self.customTwitterButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session, NSError *error) { // do operations as per your wish }]; 
+1
source

Twitter provided a separate document to enter the documentation. Create your custom button in xib or storyboard, give it a selector and add a method to enter twitter. Here is an example:

 - (IBAction)btnTwitterLogin_pressed:(id)sender { [[Twitter sharedInstance] logInWithCompletion:^ (TWTRSession *session, NSError *error) { if (session) { NSLog(@"%@", [session userID]); NSLog(@"%@", [session userName]); NSLog(@"%@", [session authToken]); NSLog(@"%@", [session authTokenSecret]); } else { NSLog(@"Error: %@", [error localizedDescription]); } }]; } 

Hope this helps others too.

+1
source

Source: https://habr.com/ru/post/987413/


All Articles