1.选择要横排显示的xib文件的view 控件。
2.选择这个view控件的 Attributes ,把其中的Orientation 设置为 Landscape
3.修改.m文件中视图转向方法成:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft);
}
原来的代码是显示成纵向的
return (interfaceOrientation == UIInterfaceOrientationPortrait);4.XXXXXXXX-Info.plist里面加“Supported interface orientations (iPad)"一项,内容设成“Landscape"
给个 UIInterfaceOrientationLandscapeRight 就可以了.
如下图:

本文详细介绍了如何通过修改XIB文件和代码,实现将特定视图设置为横屏显示,并确保iPad设备上正确适配。通过调整Orientation属性和Info.plist配置,以及自定义视图转向方法,可以轻松实现横屏布局。

被折叠的 条评论
为什么被折叠?



