iphone 开发 横版 横排的视图

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

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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 就可以了.

如下图:



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值