iOS: Autolayout not showing correct size in iPhone -


I am creating an app, in which I have to sign down and show two buttons on login name. I have used Autolayout for this, I need to support all the iPhone devices. It's working up to the iPhone 5S and is showing the right. However its width is not expanding in the iPhone 6 signup button. I'm doing something wrong, but I'm not sure that my code is below.

The attachment is also a screenshot. Enter image details here

  NSDermutation * View project = @ {@ "login button ": Self.loginButton}; // Define LoginButton Size NSArray * constraint_H = [NSLayoutConstraint constraintsWithVisualFormat: @ "V: [loginButton (52)]" option: 0 metric: views zero: viewsDictionary]; NSArray * constraint_V = [NSLayoutConstraint Visual format with constraints: @ "H: [LoginButton (160)]" option: 0 metric: zero view: viewsDictionary]; [Self. Loginbutton add consultancy: compulsion_h]; [Self.loginButton addConstraints: constrain_V]; // Long Post POSTISTATION NSARRA * constraint_POS_V = [NSLayout content with restrictions exclusively: @ "V: [LoginButtons] -0- |" Options: 0 metric: zero view: viewsDictionary]; NSArray * constraint_POS_H = [NSLayoutConstraint constraintsWithVisualFormat: @ "H: | -0- [LoginButton]" option: 0 metric: zero view: viewsDictionary]; [Self.view addConstraints: constraint_POS_V]; [Self.view addConstraints: constraint_POS_H]; // Define SignInButton Size NSDictionary * yellowDictionary = @ {@ "signInButton": self.signInButton}; NSArray * yellow_constraint_H = [NSLayoutConstraint constraintsWithVisualFormat: @ "V: [signInButton (52)]" option: 0 metric: views zero: yellowDictionary]; NSArray * yellow_constraint_V = [NSLayoutConstraint constraintsWithVisualFormat: @ "H: [Sign InButton (160)]" option: 0 metric: zero view: yellow-object]; [Self.signInButton addConstraints: yellow_constraint_H]; [Self.signInButton addConstraints: yellow_constraint_V]; // Define signinview postian NSArray * yellowconstraint_POS_V = [NSLayoutConstraint constraintsWithVisualFormat: @ "V: [sign in] -0- |" Options: 0 metric: zero view: yellowDictionary]; NSArray * yellowconstraint_POS_H = [NSLayoutConstraint constraintsWithVisualFormat: @ "H: | -161- [signInButton]" option: 0 metric: views zero: yellowDictionary]; [Self.view addConstraints: yellowconstraint_POS_V]; [Self.view addConstraints: yellowconstraint_POS_H];  

You have set the login button and signup button size to 160 each. There is only one problem.

You need to calculate the width of the screen and partly obstruct the width of the buttons.

The code below will solve your problem

CGSize screenSize = [UIScreen mainScreen] .bounds.size; NSArray * constraint_H = [NSLayoutConstraint constraintsWithVisualFormat: @ "V: [loginButton (52)]" option: 0 metric: zero view: viewsDictionary]; NSArray * constraint_V = [NSLayoutConstraint constraintsWithVisualFormat: [NSString stringWithFormat: @ "H: [loginButton (% f)]", ScreenSize.width / 2] Options: 0 metric: views zero: viewsDictionary]; [Self. Loginbutton add consultancy: compulsion_h]; [Self.loginButton addConstraints: constrain_V]; // Long Post POSTISTATION NSARRA * constraint_POS_V = [NSLayout content with restrictions exclusively: @ "V: [LoginButtons] -0- |" Options: 0 metric: zero view: viewsDictionary]; NSArray * constraint_POS_H = [NSLayoutConstraint constraintsWithVisualFormat: @ "H: | -0- [LoginButton]" option: 0 metric: zero view: viewsDictionary]; [Self.view addConstraints: constraint_POS_V]; [Self.view addConstraints: constraint_POS_H]; // Define SignInButton Size NSDictionary * yellowDictionary = @ {@ "signInButton": self.signInButton}; NSArray * yellow_constraint_H = [NSLayoutConstraint constraintsWithVisualFormat: @ "V: [signInButton (52)]" option: 0 metric: zero view: yellowDictionary]; NSArray * yellow_constraint_V = [NSLayoutConstraint constraintsWithVisualFormat: [NSString stringWithFormat: @ "H: [signInButton (% f)]", ScreenSize.width / 2] Options: 0 metric: views zero: yellowDictionary]; [Self.signInButton addConstraints: yellow_constraint_H]; [Self.signInButton addConstraints: yellow_constraint_V]; // Define signinview postian NSArray * yellowconstraint_POS_V = [NSLayoutConstraint constraintsWithVisualFormat: @ "V: [sign in] -0- |" Options: 0 metric: zero view: yellowDictionary]; NSArray * yellowconstraint_POS_H = [NSLayoutConstraint constraintsWithVisualFormat: [NSString stringWithFormat: @ "H: | -% f- [signInButton]", (screenSize.width / 2) +1] Option: 0 metric: zero view: yellowDictionary]; [Self.view addConstraints: yellowconstraint_POS_V]; [Self.view addConstraints: yellowconstraint_POS_H];


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -