bvd*_*bvd 7 objective-c ios5 xcode4.2
我正在为iOS 5开发一个必须以横向模式运行的应用程序.我的问题是我最初无法让它翻转.
我已经尝试将"初始界面方向"添加到"横向(右侧主页按钮)"并将以下方法添加到我的视图控制器:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
Run Code Online (Sandbox Code Playgroud)
我可以围绕它应该如何工作.(我在这里找到了代码)
我也想知道如何使用Xcode 4.2项目设置中提供的"支持的设备方向",它似乎没有做任何事情.
我一直在寻找网站,并没有找到一个解决我的问题的例子.
谢谢.
Sau*_*abh 16
在应用程序的Info.plist文件中,添加UIInterfaceOrientation
密钥并将其值设置为横向模式.对于横向方向,您可以将此键的值设置为
UIInterfaceOrientationLandscapeLeft
或
UIInterfaceOrientationLandscapeRight.
在横向模式下布置视图,并确保正确设置其自动调整大小选项.
覆盖视图控制器的shouldAutorotateToInterfaceOrientation:方法,仅针对所需的横向方向返回YES,针对纵向方向返回NO.
vis*_*shy 11
在appDelegate中使用以下内容
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
Run Code Online (Sandbox Code Playgroud)
还设置了所需的方向
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
//Here are some iOS6 apis, used to handle orientations.
- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0)
- (NSUInteger)supportedInterfaceOrientations - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21956 次 |
| 最近记录: |