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 就可以了.
如下图: