ios5 - UIView horizontal centering using autoresizingmask not working -


i having problems in centering uiview in middle of detail view in master-detail application template in ios5. view of width less ipad screen , should appear in center irrespective of device orientation. here's tried....

- (void)viewdidload {     [super viewdidload];      [self.view setautoresizingmask:(uiviewautoresizingflexibleleftmargin|uiviewautoresizingflexiblerightmargin)];     [self.view.layer setborderwidth:2.0f];     [self.view.layer setbordercolor:[[uicolor orangecolor] cgcolor]];      // additional setup after loading view, typically nib.     uiview *somecontainerview = [[uiview alloc] initwithframe:cgrectmake(0, 0, 600.0f, 56.0f)];     [somecontainerview.layer setborderwidth:2.0f];     [somecontainerview.layer setbordercolor:[[uicolor greencolor] cgcolor]];     [somecontainerview setautoresizingmask:(uiviewautoresizingflexibleleftmargin|uiviewautoresizingflexiblerightmargin)];     [self.view addsubview:somecontainerview];      [self configureview]; } 

here's how view appears

enter image description here

can tell me missing on here????

okay here's solved problem. when creating uiview, changed this

cgrectmake((0, 0, 660.0f, 56.0f)]; 

to this...

cgrectmake((self.view.bounds.size.width-660.0f)/2, 0, 660.0f, 56.0f)]; 

since using autoresizingmask flexible left/right margin, hence need position uiview in center autoresizing work magic maintaining left/right margins when view rotates.


Comments

Popular posts from this blog

django - How can I change user group without delete record -

java - Need to add SOAP security token -

java - EclipseLink JPA Object is not a known entity type -