如何使横向Xcode 5应用程序项目在横向方向上启动?
我创build了一个“单一视图应用程序”项目,并将所有选项设置为启动并仅支持横向导向。 但该应用程序启动与纵向窗口的窗口。
控制台输出说application:didFinishLaunchingWithOptions:
之后的窗口application:didFinishLaunchingWithOptions:
是:
{{0, 0}, {768, 1024}}
我添加了一个标准的系统button来查看ViewController来说明该应用程序是风景,而不是肖像,但该窗口是肖像。
由于堆栈溢出具有白色背景,因此我可以在Photoshop中将右侧的部分着色为灰色,以便您看到它:
在application:didFinishLaunchingWithOptions:
我把窗口application:didFinishLaunchingWithOptions:
红色。 显然不是横向的。
我已经尝试了所有我知道的技巧:
1)Info.plist包含UISupportedInterfaceOrientations关键字:UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight
2)Info.plist包含UISupportedInterfaceOrientations〜ipad关键字:UIInterfaceOrientationLandscapeLeft和UIInterfaceOrientationLandscapeRight
3)Info.plist包含初始界面方向的UIInterfaceOrientation键:UIInterfaceOrientationLandscapeRight
4)点击Xcode中的项目,然后取消选中所有肖像选项,只检查横向选项:
5)AppDelegate和ViewController都有:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationIsLandscape(interfaceOrientation); } - (NSUInteger)supportedInterfaceOrientations { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; } - (BOOL)shouldAutorotate { return YES; }
6)AppDelegate有:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { return UIInterfaceOrientationMaskLandscapeLeft | UIInterfaceOrientationMaskLandscapeRight; }
Xcode创build了两个故事板文件。 我现在只在iPad上进行testing。 一个是Main_iPad.storyboard,它显示了一个纵向的视图控制器。 但它只是一个模拟的接口指标。 改为景观和预期没有效果。
在应用程序启动过程中,我检查了UIScreen边界,它也是清晰的肖像,而不是风景:
CGRect screenBounds = [[UIScreen mainScreen] bounds]; // {{0, 0}, {768, 1024}}
我怎样才能使它在横向上发射并在横向上创build一个窗口?
我之前有过类似的问题,所以也许他们有关系…
我有一个问题,因为我在我的视图控制器的initWithNibName:bundle:
编程方式创build我的视图,并且无论出于何种原因,这样做都是在纵向模式下定位新视图,而应用程序的其余部分正在运行横向。
我发现这个问题的两个修复。 1)使用你的故事板创build视图,而不是编程或2)移动代码来创build视图控制器的initWithNibName:bundle:
方法的视图,并将其放置在视图控制器的-viewDidLoad:
方法是这样的:
-(void)viewDidLoad { //Create your view programmatically UIView *view = [[UIView alloc] initWithFrame:self.view.frame]; //Customize view [self.view addSubview:view]; }
这是我遇到的类似问题的解决scheme。 虽然我认识到我们程序员有很多方法可以使事情做不到正确的方式,但我希望这是答案!
在界面生成器中,单击视图控制器 ,然后在大小检查器开关模拟大小 自由forms (从固定 ),input宽度为1024, 高度为768。 这个对我有用。
- 当用户点击特定的date时,将会显示一个提醒标题
- 界面生成器中的UIButton的活力效应
- 如何configurationNSURLSessionConfiguration到NSObject类?
- 目标C到Swift代码转换,似乎无法正确处理在Swift中的字节
- 由于未捕获exception'CALayerInvalidGeometry',原因:'CALayer界限包含NaN:'
- Bootstrap 3 iPad下拉不起作用
- 无法添加目标UIButton – 无法识别的select发送到实例,尽pipe方法在同一个类
- AFNetworking v3.1.0 multipartFormRequestWithMethod上传带引号的JSON数值
- swift ios数据持久性UIImage