Я пытаюсь разработать приложение в 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
В любом случае, приложение открывается, но при открытии вылетает.