Google+ SDK pour iOS Ajouter Signin bouton par programmation

Comme pour G+ docs ici: https://developers.google.com/+/mobile/ios/connexion

Le bouton de connexion peuvent être ajoutés à l'aide d'un XIB ou par programmation dans un UIViewController.

J'ai un TableViewController et je vais ajouter le G+ Signin bouton que l'accessoire vue d'une ligne de tableau:

subtitleCell.accessoryView = self.googlePlusSignInButton;

où la signin bouton va être initialisé de la façon suivante:

-(void) setGooglePlusButtons {

    self.googlePlusSignInButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];


    UIImage *backgroundButtonImage = [UIImage imageNamed:@"bt_search_cancel.png"];

    googlePlusSignInButton_.frame = CGRectMake(0.0f,
                                               0.0f,
                                               backgroundButtonImage.size.width,
                                               backgroundButtonImage.size.height);

    googlePlusSignInButton_.titleLabel.textColor = [UIColor whiteColor];
    googlePlusSignInButton_.titleLabel.font = [UIFont boldSystemFontOfSize:11.0f];
    googlePlusSignInButton_.titleLabel.numberOfLines = 2;

    googlePlusSignInButton_.titleLabel.shadowColor = [UIColor darkGrayColor];
    googlePlusSignInButton_.titleLabel.shadowOffset = CGSizeMake(0.0f,
                                                                 -1.0f);

    [googlePlusSignInButton_ setTitle:NSLocalizedString(@"UI_BUTTONS_LOGIN", @"")
                             forState:UIControlStateNormal];

    [googlePlusSignInButton_ setBackgroundImage:backgroundButtonImage
                                       forState:UIControlStateNormal];


    //Make sure the GPPSignInButton class is linked in because references from
    //xib file doesn't count.
    [GPPSignInButton class];

    GPPSignIn *signIn = [GPPSignIn sharedInstance];

    signIn.delegate = self;
    signIn.shouldFetchGoogleUserEmail = signIn.shouldFetchGoogleUserEmail;
    signIn.actions = [NSArray arrayWithObjects:
                      @"http://schemas.google.com/ListenActivity",
                      nil];

}

Le bouton est mis en place à la viewDidLoad:

- (void)viewDidLoad {

    [super viewDidLoad];

    [self setGooglePlusButtons];

//...

La UIViewControlled a une interface pour le compte d'un délégué:

@interface MXMSettingsTableViewController () <GPPSignInDelegate>
@end

Il semble que le délégué n'est pas appelé ou partagées bouton de connexion n'est pas lié à l'instance du contrôleur:

//GPPSignInDelegate

- (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
                   error:(NSError *)error {
   ///....
}

Je suppose que

//Make sure the GPPSignInButton class is linked in because references from
//xib file doesn't count.
[GPPSignInButton class];

est la liaison entre les ViewController instance de bouton:

//The button that handles Google+ sign-in.
@property (retain, nonatomic) GPPSignInButton *googlePlusSignInButton;

mais il ya quelque chose de mal dans cette mise en œuvre, je ne peux pas comprendre.

OriginalL'auteur loretoparisi | 2013-09-04