我在製作應用程序,需要在模態屏幕中顯示圖像。在我的xib中,我製作了UIImage視圖的全屏大小。當圖像顯示時,它在屏幕中居中。這在iPhone5上正常工作。但是,當我回到測試4時,無論我如何使圖像居中在屏幕上,導致圖像顯示在頁面中間一半,因爲圖像視圖太大,我似乎無法縮小圖像視圖爲屏幕。滾動視圖似乎調整正確,我不知道爲什麼圖像wiew不會。症狀的下面 相關代碼的4S無法在iPhone4和iPhone5之間調整UIImageView的大小
屏幕截圖:
[self.scrollView setZoomScale:self.scrollView.minimumZoomScale animated:YES];
[self.myView setTranslatesAutoresizingMaskIntoConstraints:YES];
[self.scrollView setTranslatesAutoresizingMaskIntoConstraints:YES];
[self.imageView setTranslatesAutoresizingMaskIntoConstraints:YES];
NSURL *url = [NSURL URLWithString:self.myImage];
NSData *data = [NSData dataWithContentsOfURL:url];
img = [[UIImage alloc] initWithData:data];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:nil];
[self.scrollView setZoomScale:self.scrollView.minimumZoomScale animated:YES];
CGSize imageSize = [self currentScreenBoundsDependOnOrientation];
self.imageView.frame = self.myView.bounds ;
self.scrollView.frame = self.myView.bounds;
imageWithAlignmentRectInsets:UIEdgeInsetsMake(0, 0, 20, 20);
您是否嘗試過調整圖像大小。我想這會修復 –
在iPhone 4和iPhone 5上產生的幀值是什麼? – Sulthan
就是這樣。主視圖框太大,所以我只是根據屏幕大小來修復它。謝謝@Sulthan – Dnaso