即使在实现了shouldAutorotateToInterfaceOrientation之后,视图也不会调整大小

时间:2012-02-10 05:27:09

标签: iphone ios ios4 ios5

我的代码, shouldAutorotateToInterfaceOrientation正在调用,我在那里返回YES但是当我旋转设备时,控制器的视图改变了它的大小,但主视图内的UIImageView不会改变它的大小。我希望它像主视图一样调整大小。

提前致谢

1 个答案:

答案 0 :(得分:2)

根据您的需要设置autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth
在代码中

imageview = [[UIImageView alloc] initWithFrame:CGRectMake(40,40,120,100)];
imageview.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin;


如果你在xib中创建了然后在IB中设置了这个,如下图所示 enter image description here