I have a problem with Cocoa Auto Layout and can\'t get my head around this problem. All I\'d like to achieve is to have two buttons always centered in a view as depicted below.<
You can achieved as below way also.
1.Take Leading space for left button, Trailing space for right button.
2.Construct Outlets for both Leading and Trailing constraints.
__weak IBOutlet NSLayoutConstraint *leadingConstraint;
__weak IBOutlet NSLayoutConstraint *trailingConstraint;
3.Caluclate constants as below formula.
NSInteger constant = (SCREEN_WIDTH - (CGRectGetWidth(leftButton.frame) + CGRectGetWidth(rightButton.frame))) / 3;
leadingConstraint.constant = constant;
trailingConstraint.constant = constant;
Hope it will helps you.