Google+ SDK für iOS Hinzufügen Signin-button programmgesteuert

Als für G+ docs hier: https://developers.google.com/+/mobile/ios/sign-in

Die Schaltfläche "anmelden" kann Hinzugefügt werden unter Verwendung einer XIB-oder programmgesteuert in einem UIViewController.

Ich habe einen TableViewController und ich werde die G+ Signin-button als Accessoire Blick auf eine Zeile in der Tabelle:

subtitleCell.accessoryView = self.googlePlusSignInButton;

wo die signin-button wird wie folgt initialisiert:

-(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];

}

Die Taste set up an der viewDidLoad:

- (void)viewDidLoad {

    [super viewDidLoad];

    [self setGooglePlusButtons];

//...

Den UIViewControlled hat eine Schnittstelle für die signin delegieren:

@interface MXMSettingsTableViewController () <GPPSignInDelegate>
@end

Scheint es, dass die Stellvertretung nicht aufgerufen wird, oder die freigegebene Schaltfläche "anmelden" ist nicht mit der Instanz des Controllers:

//GPPSignInDelegate

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

Ich gehe davon aus, dass

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

ist die Verknüpfung der ViewController Instanz-Taste:

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

aber es ist etwas falsch in dieser Implementierung kann ich nicht herausfinden.

InformationsquelleAutor loretoparisi | 2013-09-04
Schreibe einen Kommentar