如何使屏幕在方向为横向时可滚动xcode
问题描述:
大家好我正在为xcode开发一个应用程序。我有许多标签,当它的方向是纵向时它看起来不错,但是当它是横向的时候,所有的标签都会相互重叠,所以我只想在横向模式下将它作为可滚动屏幕。请帮助我提前致谢。如何使屏幕在方向为横向时可滚动xcode
答
添加UIScrollView in self.view。
现在根据它的方向和其内容大小设置yourScrollView的框架。但是在照片框架和内容大小将相等,因此不会滚动。
现在,在景观,框架和内容的大小将不相等,就会出现滚动
注意:根据定向
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(UIInterfaceOrientationIsLandscape(interfaceOrientation))
{
[yourScrollView setFrame:CGRectMake(0,0,320,460)];
[yourScrollView setContentSize:CGSizeMake(320,460)];
//change frame of UIELement(labels) here according to orientation
}
else
{
[yourScrollView setFrame:CGRectMake(0,0,480,300)];
[yourScrollView setContentSize:CGSizeMake(480,460)];
//change frame of UIELement(labels) here according to orientation
}
return YES;
}
这是iOS的调整UIlements的名气?如果这样标记'ios'。 – *foe
数百个问题要求这个,你有没有搜索这个问题,这也是相当广泛的问题。检查出这些线程 - http://*.com/questions/10696819/orientation-handling-in-interface-builder,http://*.com/questions/11075600/handling-ios-device-orientation – rishi
亚是它。我正在开发ios5 –