[英]Scroll view content size should adjust according to orientation
My code is [scrllView setContentSize:CGSizeMake(self.view.bounds.size.width, 1000)];
我的代码是[scrllView setContentSize:CGSizeMake(self.view.bounds.size.width, 1000)];
so that its width appear on whole screen. 使其宽度显示在整个屏幕上。 But when I am changing the orientation to landscape, its width is not adjusting. 但是,当我将方向更改为横向时,其宽度没有调整。 I think it is not working because i am doing it in viewDidLoad
method, .So it will calulate the width only once. 我认为这是行不通的,因为我正在viewDidLoad
方法中执行此操作。因此它将仅计算一次宽度。 But what will be the possible solution of this. 但是,这可能是解决方案。 scrLlView
Should adjust width scrLlView
应该调整宽度
try this 尝试这个
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation;
{
//change sub view of scrollview accordingly to orientation
if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation]))
yourScrollView.frame = CGRectMake(0,0,320,460);
yourScrollView.contentSize = CGSizeMake(320,460);//change accordingly
else
yourScrollView.frame = CGRectMake(0,0,480,300);
yourScrollView.contentSize = CGSizeMake(480,500); //change accordingly
return YES;
}
[yourScrollView setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.