Tim*_*Tim 4 cocoa-touch objective-c orientation ios
我有一个用旧版Xcode编写的应用程序.现在我正在使用Xcode 4.6.1.这是我从另一个在公司外部开发的开发人员继承的应用程序.
这个应用程序的一个问题是它的界面.它应该默认为LandscapeLeft(这是pList文件中设置的值).该应用程序忽略此指令,而是默认为纵向模式.
我是否需要做些什么来强制代码来兑现这个值?我对iOS/Objective-C比较陌生.代码编译并运行,只是界面没有做我想要的.
这是一个更容易,因为这是一个仅限iPad的应用程序.
编辑 我已经尝试将以下代码添加到我的一个有问题的viewControllers,但它没有被尊重.关于如何强迫这种观点进行景观的任何想法?(IDE中是否有设置 - 看起来Xcode曾经有一个方向属性,但我在4.6.1中找不到它)
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
return ((interfaceOrientation==UIInterfaceOrientationMaskLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationMaskLandscapeRight));
}
- (NSUInteger) supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeLeft;
}
- (NSInteger) supportedInterfaceOrientationsForWindow
{
return UIInterfaceOrientationMaskLandscape;
}
- (BOOL) shouldAutoRotate
{
return YES;
}
Run Code Online (Sandbox Code Playgroud)
我希望这能帮到您.在AppDelegate.m
课堂上添加其中一个(你想要的方向)方法
在横向模式下强制完全运行应用程序:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskLandscape;
}
Run Code Online (Sandbox Code Playgroud)
在纵向模式下强制完全运行应用程序:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)