Tag: uiinterfaceorientation contentize

UIScrollview方向更改时的内容大小

我有一个分页滚动查看。 在viewDidLoad我检查,如果当前的方向是风景,然后我设置其内容的高度440 if (UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) { [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages,340)]; } else if (UIDeviceOrientationIsLandscape([[UIDevice currentDevice] orientation])) { [scroll setFrame:CGRectMake(0,0,480,480)]; [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 440)]; } 一切工作正常滚动视图滚动光滑,没有对angular线滚动。 但是当方向改变时, 我必须设置滚动视图的框架和内容再次,我设置如下 -(void)orientationChanged:(id)object { if(UIDeviceOrientationIsPortrait([[UIDevice currentDevice] orientation])) { self.scroll.frame = [[UIScreen mainScreen]bounds]; [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 340)]; } else { self.scroll.frame = CGRectMake(0,0,480,480); [scroll setContentSize:CGSizeMake(self.scroll.frame.size.width*numberOfPages, 600)]; } } 我不明白为什么我必须在横向模式下将内容大小的高度设置为600,而这还不够。 它增加了一个问题,滚动视图开始对angular线滚动,我不想要,因为它看起来很奇怪。 任何人都可以帮助我了解我错过了什么和什么? 我已经设置scrollview的自动调整掩码为 [scroll setAutoresizingMask:UIViewAutoresizingFlexibleLeftMargin|UIViewAutoresizingFlexibleRightMargin|UIViewAutoresizingFlexibleHeight]; […]