[英](iphone)autorotation does not change my view's size
I am currently facing the conundrum that when I rotate my device, the view does not change its size. 我目前面临的难题是,当我旋转设备时,视图不会改变其大小。 The view is a imageView embedded in a scroll view.
视图是嵌入在滚动视图中的imageView。 The view controller is embedded in a navigation controller.
视图控制器嵌入在导航控制器中。 Here's core code for my view controller.
这是我的视图控制器的核心代码。
- (void)viewDidLoad
{
[super viewDidLoad];
[[self navigationItem] setTitle:self.imageTitle];
[self.imageView setImage:self.myImage];
self.scrollView.delegate = self;
self.scrollView.contentSize = self.imageView.image.size;
double scale = self.imageView.bounds.size.width * 1.0 / self.myImage.size.width;
if (scale > self.imageView.bounds.size.height * 1.0 / self.myImage.size.height)
scale = self.imageView.bounds.size.height * 1.0 / self.myImage.size.height;
self.imageView.frame = CGRectMake(0, 0, self.imageView.image.size.width,
self.imageView.image.size.height);
[self.scrollView setZoomScale:scale];
}
Typically some information about the view is not updated until later than viewDidLoad. 通常,有关视图的某些信息在viewDidLoad之后才会更新。
As prior to completion of viewDidLoad. 在完成viewDidLoad之前。 The nib is not loaded completely.
笔尖未完全加载。 So you may not get the size and other details about it.
因此,您可能无法获得有关它的大小和其他详细信息。
Moving the view size query to viewWillAppear
or viewDidAppear
should solve the issue. 将视图大小查询移动到
viewWillAppear
或viewDidAppear
应该可以解决问题。
Hope this helps you. 希望这对你有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.