objective c - iOS: Is it possible to resize Twitter and/or Facebook login button? -


i want add twitter , facebook authentication buttons mobile app. using xcode 6 , newest sdks of facebook , twitter. managed integrate these 2 buttons auth screen, sizes different, resulting in horrible design issue ; )

enter image description here

- (void)viewdidload {     [super viewdidload];     // facebook login     fbsdkloginbutton *fblogin = [[fbsdkloginbutton alloc] init];     fblogin.center = self.view.center;     [self.view addsubview:fblogin];      // twitter login     twtrloginbutton *twlogin = [twtrloginbutton buttonwithlogincompletion:^(twtrsession *session, nserror *error) {         // ...     }];     twlogin.center = cgpointmake(self.view.center.x, self.view.center.y+50.0);     [self.view addsubview:twlogin]; } 

somebody idea how resize buttons ?

edit-1: based on sega-zero's answer following error:

2015-05-31 11:20:12.204 testapp[10477:3081595] [fabric] unable locate application icon 2015-05-31 11:20:12.251 testapp[10477:3081595] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: 'unable parse constraint format:  expected view  h:fblogin(==twlogin)    ^' 

edit-2: based on sega-zero's corrected answer following error:

2015-05-31 11:39:11.433 quiz cup[10486:3083839] [fabric] unable locate application icon 2015-05-31 11:39:11.488 quiz cup[10486:3083839] view hierarchy not prepared constraint: <nslayoutconstraint:0x170088840 fbsdkloginbutton:0x124e12690'log in'.width == twtrloginbutton:0x124e15840.width>     when added view, constraint's items must descendants of view (or view itself). crash if constraint needs resolved before view hierarchy assembled. break on -[uiview _viewhierarchyunpreparedforconstraint:] debug. 2015-05-31 11:39:11.490 quiz cup[10486:3083839] view hierarchy unprepared constraint.     constraint: <nslayoutconstraint:0x170088840 fbsdkloginbutton:0x124e12690'log in'.width == twtrloginbutton:0x124e15840.width>     container hierarchy:  <fbsdkloginbutton: 0x124e12690; baseclass = uibutton; frame = (296.5 497; 175 30); opaque = no; layer = <calayer: 0x170036d80>>    | <uibuttonlabel: 0x124e147a0; frame = (0 0; 0 0); text = 'log in'; opaque = no; userinteractionenabled = no; layer = <_uilabellayer: 0x170087f80>>     view not found in container hierarchy: <twtrloginbutton: 0x124e15840; baseclass = uibutton; frame = (244 542; 280 40); clipstobounds = yes; opaque = no; layer = <calayer: 0x1740322e0>>     view's superview: <uiview: 0x124e11960; frame = (0 0; 768 1024); autoresize = w+h; layer = <calayer: 0x170036c00>> 2015-05-31 11:39:11.497 quiz cup[10486:3083839] *** terminating app due uncaught exception 'nsgenericexception', reason: 'unable install constraint on view.  constraint reference outside subtree of view?  that's illegal. constraint:<nslayoutconstraint:0x170088840 fbsdkloginbutton:0x124e12690'log in'.width == twtrloginbutton:0x124e15840.width> view:<fbsdkloginbutton: 0x124e12690; baseclass = uibutton; frame = (296.5 497; 175 30); opaque = no; layer = <calayer: 0x170036d80>>' 

just set minumum width/height constraints + equal width/height both buttons. if prefer via code, may this:

[fbloginparent addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:[fblogin(==twlogin)]" options:0 metrics:nil views:nsdictionaryofvariablebindings(fblogin, twlogin)]]; [fbloginparent addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:[fblogin(==twlogin)]" options:0 metrics:nil views:nsdictionaryofvariablebindings(fblogin, twlogin)]]; [fblogin addconstraints:[nslayoutconstraint constraintswithvisualformat:@"h:[fblogin(>=100)]" options:0 metrics:nil views:nsdictionaryofvariablebindings(fblogin)]]; [fblogin addconstraints:[nslayoutconstraint constraintswithvisualformat:@"v:[fblogin(>=26)]" options:0 metrics:nil views:nsdictionaryofvariablebindings(fblogin)]]; 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -