我最近才开始学习使用 Xcode 和 Objective-C。像往常一样,我决定从学习如何创建 Hello, World 应用程序开始。出于某种原因,即使我正在为纵向模式设计一切,它仍然在模拟器和我的 iPad 2 上显示横向模式。 在 Xcode 中,在 iPad 上的模拟器中
这是视图控制器的代码,如果有帮助的话。
#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
编辑:红色背景