2012-02-25 16 views
0

私はフルスクリーンスクロールビューを持っています。私はそれに2つの画像をロードしています。風景モードではうまく動作しますが、ポートレートモードでは画像が画面より大きくなるため、一部の画像しか見ることができません。それはself.view.boundsはクイックフィックスと、右の画面サイズself.view.boundsがポートレートで表示されない

CGRect frameForView1 = self.view.bounds; 
CGRect frameForView2 = self.view.bounds; 

image1 = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:fullpath]]; 
[image1 setFrame:frameForView1]; 
[self.scrollView addSubview:image1]; 
[image1 release]; 

frameForView2.origin.x = frameForView2.size.width; 
image2 = [[UIImageView alloc] initWithImage:[UIImage imageWithContentsOfFile:fullpath]]; 
[image2 setFrame:frameForView2]; 
[self.scrollView addSubview:image2]; 
[image2 release]; 

self.scrollView.contentSize = CGSizeMake(self.scrollView.frame.size.width * 2, self.scrollView.frame.size.height); 

答えて

1

を提供していないことが表示されます、あなたは画面がであるものの向きをチェックし、与えられたオリエンテーションで知られるビューの値をハードコーディングする必要があります。

BOOL isLandscape = UIDeviceOrientationIsLandscape([UIDevice currentDevice].orientation); 
if(isLandscape) 
    //do something with landscape frame values 
else(doSomethingElse) 
    //do something with portrait frame values 
+1

'[UIScreen mainScreen] .bounds'はローテーションでは変更されませんが、ビューコントローラのビューの境界は変更されます。 (デフォルトの動作、すなわち標準の自動サイズ変更マスクを仮定して) – NJones

関連する問題