简体   繁体   English

Xcode应用程序陷入横向模式

[英]Xcode app is stuck in landscape mode

I've just recently begun learning to use Xcode and Objective-C. 我刚刚开始学习使用Xcode和Objective-C。 As usual, I decided to begin by learning how to create a Hello, World app. 像往常一样,我决定开始学习如何创建一个Hello,World应用程序。 For some reason, even though I'm designing everything for portrait mode, it keeps showing landscape mode in the simulator and on my iPad 2. 出于某种原因,即使我正在为肖像模式设计所有内容,它仍然在模拟器和iPad 2上显示横向模式。 在Xcode中 In Xcode 在Xcode中 在iPad上的模拟器中 In the simulator an on the iPad 在iPad上的模拟器中

Here is the code of the view controller, if that helps at all. 这是视图控制器的代码,如果这有帮助的话。

#import "LCViewController.h"

@interface LCViewController ()

@end

@implementation LCViewController
@synthesize helloButton;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
}

- (void)viewDidUnload
{
    [self setHelloButton:nil];
    [super viewDidUnload];
    // Release any retained subviews of the main view.
}

    - (BOOL)shouldAutorotateToInterfaceOrientation:    (UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}

- (IBAction)showAlert:(id)sender {
    UIAlertView* alert = [[UIAlertView alloc] initWithTitle: @"Hello!"
                                                    message:@"Hello, world!"
                                                   delegate:nil
                                          cancelButtonTitle:@"Close"
                                          otherButtonTitles:nil];
    [alert show];

    [helloButton setTitle:@"I was clicked!" forState:UIControlStateNormal];
}
@end

EDIT: With Red background 编辑:红色背景 在此输入图像描述在此输入图像描述

Supported orientations was accidentally set to landscape. 支持的方向被意外设置为横向。 Set orientation on the project main screen in the Supported Orientations section or in the plist file. 在“支持的方向”部分或plist文件中的项目主屏幕上设置方向。

在属性检查器中查看为“模式”选择了哪种语音。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM