ios - Align a programmatically created UIView's center with an auto-layout view's center -


i created uiview in storyboard centered in center of view controller auto layout, , working fine across different device sizes. call largerview.

however, programmatically create smaller uiview called smallerview , center view smallerview.center = largerview.center.

i running issue given auto layout used on largerview, whenever use method above, smallerview never centers largerview.center. noticed take center coordinates of largerview appear in storyboard, based on specific layout of device using (in case, previous iphone 5's dimensions), not updated center affected auto layout.

a similar issue may discussed here, except based on swift. know how constraints created programmatically, unsure how "refreshed" coordinates of view after auto layout applied.

thanks!

you need override following method in view controller:

- (void)viewdidlayoutsubviews  {     [super viewdidlayoutsubviews];     self.smallview.frame.center = self.largeview.frame.center; } 

Comments

Popular posts from this blog

java - Plugin org.apache.maven.plugins:maven-install-plugin:2.4 or one of its dependencies could not be resolved -

Round ImageView Android -

How can I utilize Yahoo Weather API in android -