views:

477

answers:

1

Hi,

I have created a UIViewController class with a background color as red. I have also created a UIView which is a subview and placed with a background image and two UIButtons on them. The coding which i give for screen orientation is

 -(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}

self.view =[[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
self.view.backgroundcolor =[UIColor redColor];
UIView *subview;
subview = [[UIView alloc] initWithFrame:CGRectMake(0,0,320,480)];
subview.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@""]];
subview.autoresizingMask = UIViewAutoResizingFlexibleWidth |UIViewAutoresizingFlexibleHeight;

Problem:

When i turn into Landscape the subview is resized with the image, but the buttons remain in the same position and i am not using any .xib file.I have created the project programmatically.Please do reply....

A: 

Override layoutSubviews for your class. You might need to explicitly call [self setNeedsLayout] from didRotateFromInterfaceOrientation

Phil Nash
Thanks for the answer. I also have another problem where i have another subview as TableView where it appears in the click of the UIButton. When i turn it into landscape, the Tableview is turned but not fits into the whole screen.Half of the screen i can see the TableView and the other half is my rootView.Please do reply me .
Cathy