【发布时间】:2011-01-21 23:31:22
【问题描述】:
我正在尝试在 XCode 中开发一个应用程序,该应用程序将在旋转时切换到新视图。
这是view1controller.h的代码:
#import UIKit/UIKit.h
@interface TestViewController : UIViewController {}
IBOutlet UIView *portrait;
IBOutlet UIView *landscape;
@property(nonatomic,retain) UIView *portrait;
@property(nonatomic,retain) UIView *landscape;
@end
这是view1controller.m的代码:
#import "view1controller.h"
@implementation TestViewController
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
if(((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight)))
{
self.view = landscape;
} else if (((interfaceOrientation == UIInterfaceOrientationPortrait) || (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))) {
self.view = portrait;
}
return YES;
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[super dealloc];
}
@synthesize portrait,landscape;
@end
无论如何,应用程序打开但打开时崩溃。
【问题讨论】:
标签: cocoa-touch ios ios4