title: Google+ SDK for iOS Add Signin button programmatically
body: <p>As for G+ docs here: <a href="https://developers.google.com/+/mobile/ios/sign-in" rel="noreferrer">https://developers.google.com/+/mobile/ios/sign-in</a></p>
  
  <p>The sign in button can be added using a XIB or programmatically in a UIViewController.</p>
  
  <p>I have a TableViewController and I'm going to add the G+ Signin button as the accessory view of a table row:</p>
  
  <pre><code>subtitleCell.accessoryView = self.googlePlusSignInButton;
  </code></pre>
  
  <p>where the signin button is going to be initialized as follows:</p>
  
  <pre><code>-(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];
  
  }
  </code></pre>
  
  <p>The button is set up at the viewDidLoad:</p>
  
  <pre><code>- (void)viewDidLoad {
  
      [super viewDidLoad];
  
      [self setGooglePlusButtons];
  
  //...
  </code></pre>
  
  <p>The UIViewControlled has an interface for the signin delegate:</p>
  
  <pre><code>@interface MXMSettingsTableViewController () &lt;GPPSignInDelegate&gt;
  @end
  </code></pre>
  
  <p>It seems that the delegate is not being called or the shared sign in button is not linked to the instance of the controller:</p>
  
  <pre><code>// GPPSignInDelegate
  
  - (void)finishedWithAuth:(GTMOAuth2Authentication *)auth
                     error:(NSError *)error {
     ///....
  }
  </code></pre>
  
  <p>I assume that </p>
  
  <pre><code>// Make sure the GPPSignInButton class is linked in because references from
  // xib file doesn't count.
  [GPPSignInButton class];
  </code></pre>
  
  <p>is linking the ViewController instance button:</p>
  
  <pre><code>// The button that handles Google+ sign-in.
  @property (retain, nonatomic) GPPSignInButton *googlePlusSignInButton;
  </code></pre>
  
  <p>but there is something wrong in this implementation I cannot figure out.</p>