0
私はscrollviewとinsdie scrollviewを使用して画像を表示するためにimageviewを使用していますが、私はシミュレータの向きを左右に変更すると左右に画像ビューとスクロールビューの位置が同じ手順を繰り返すうちに方向が変わり、スクロールビューとイメージビューが表示される段階になります。私は肖像画のためのビューと風景のためのビューの2つのビューを使用しました.iはdiffを表示する必要があります。ポートレートモードとランドスケープモードの画像は誰でも私を助けることができます..あらかじめいくつかのサンプルコードがあります。スクロールビューが変更方向として変更されます
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(interfaceOrientation==UIInterfaceOrientationPortrait ||interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown)
{
return YES;
} else if(interfaceOrientation==UIInterfaceOrientationLandscapeLeft ||interfaceOrientation==UIInterfaceOrientationLandscapeRight)
{
return YES;
}
return YES;
}
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation
{
UIInterfaceOrientation orientation = [[UIDevice currentDevice] orientation];
if(orientation==UIInterfaceOrientationPortrait || orientation==UIInterfaceOrientationPortraitUpsideDown)
{CGRect frame=CGRectMake(0,45,320,480);
[sample_scroll_view setFrame:frame];
sample_scroll_view.contentSize = CGSizeMake(2560,275);
sample_scroll_view.pagingEnabled=YES;
sample_scroll_view.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
sample_scroll_view.autoresizesSubviews = YES;
}
else if (orientation==UIInterfaceOrientationLandscapeLeft || orientation==UIInterfaceOrientationLandscapeRight)
{
CGRect frame=CGRectMake(0,45,480,275);
[scroll_view2 setFrame:frame];
scroll_view2.contentSize = CGSizeMake(3140,275);
scroll_view2.maximumZoomScale = 4.0;
scroll_view2.minimumZoomScale = 0.75;
scroll_view2.bounces = NO;
scroll_view2.pagingEnabled=YES;
sample_scroll_view.autoresizingMask =
(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight);
sample_scroll_view.autoresizesSubviews = YES;
}
}