开发者

How to autoresize the subviews for screen orientations in iPhone programmatically?

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开发者_StackOverflow) 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....


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜