ragnarius
ragnarius

Reputation: 5823

How and when to adjust the position of subviews?

I have created the layout of my main view in a xib-file, but I want to adjust it somewhat in runtime.

I call my adjusting code from viewDidAppear. The code sets the upper left corner of a button to (0,0), but the button becomes partly hidden by the status bar!

(I call the same code when the veiw rotates and then it works fine!)

Can someone explain this?

code snippet:

-(void) viewDidAppear:(BOOL) animated{
    [super viewDidAppear:animated];

    CGRect rc = CGRectMake(0, 0, 128, 128);
    [buttBack setFrame:rc];

}//viewDidAppear

Upvotes: 0

Views: 139

Answers (1)

Oliver
Oliver

Reputation: 23550

Put some dummy buttons at the 4 angles of your view. When runned, you wil be able to see if they disapear partially out of the screen / under the tool bar. If yes, that would explain why setting 0/0 for the origin of your button does the same thing.

Also, check that the view that contains the button you want to adjust has all its auto-adjust properties well defined. Verify also that "toolbar" simulation is ON on the main view into your XIB.

After having done that, check also that your view's H and W are correct (not too big nor loaw), but this is just for conscience, having adjusted the auto-adjust properties should deal with such errors.

Upvotes: 1

Related Questions