[英]scrollview changes as change orientation
我正在創建一個應用程序,其中我使用了scrollview和insdie scrollview我使用了imageview來顯示圖像。但是當我將模擬器的方向更改為左/右橫向時,隨着方向的增加,imageview和scrollview的位置向左移動,同時重復相同的過程滾動觀看和圖像觀看消失的階段。 我在視圖中使用了兩個視圖,一個用於縱向視圖,另一個用於橫向視圖。我必須顯示差異。 用於人像模式和橫向模式的圖像,因此任何人都可以幫助我..謝謝。這里有一些示例代碼。
- (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;
}
}
您可以在xib文件的“視圖”標簽下的自動調整大小模式下進行一些設置。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.