Converting the app to landscape

本文介绍了如何将iOS应用从竖屏模式转换为横屏模式的三个步骤:修改BullsEyeViewController.xib文件使其支持横屏;更新BullsEyeViewController.m文件中的代码允许视图控制器自动旋转到横屏模式;更改应用程序的支持的设备方向设置。

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

To convert our app from portrait into landscape, we have to do three things:

1 Make the view from BullsEyeViewController.xib landscape instead of portrait.

2 Change one line of code in BullsEyeViewController.m that will allow the view controller to autorotate to landscape mod.

3 Change the "Supported Device Orientations" settings of our app.


in iOS 5



- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
{
	return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown); 
}
This particular piece of functionality is queried by UIKit when the user rotates his iPhone. UIKit essentially asks the view controller: "Do you want to rotate to this new orientation?"

YES NO


if only allow for landscape, change

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation

{
return UIInterfaceOrientationIsLandscape(interfaceOrientation);


cmd left or right     change the orientation in simulator



To change the initial orientation





评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值