Ios 针对不同的方向加载不同的.xib
在我的应用程序中,我想为不同的方向加载不同的.xib,即一个用于纵向,一个用于横向 我搜索了它,也找到了解决方案,但它对我不起作用。任何人都可以帮我解决这个问题 这是我的密码:-Ios 针对不同的方向加载不同的.xib,ios,objective-c,orientation,nib,Ios,Objective C,Orientation,Nib,在我的应用程序中,我想为不同的方向加载不同的.xib,即一个用于纵向,一个用于横向 我搜索了它,也找到了解决方案,但它对我不起作用。任何人都可以帮我解决这个问题 这是我的密码:- - (void)viewDidLoad { [super viewDidLoad]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultC
- (void)viewDidLoad {
[super viewDidLoad];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:) name:UIDeviceOrientationDidChangeNotification object:[UIDevice currentDevice]];
}
- (void) orientationChanged:(NSNotification *)note {
UIDevice * device = note.object;
NSArray *array;
UIView *mainView;
if (device.orientation == UIDeviceOrientationPortrait || device.orientation == UIDeviceOrientationPortraitUpsideDown) {
array = [[NSBundle mainBundle] loadNibNamed:@"NewViewController" owner:self options:nil];
mainView = [array objectAtIndex:0];
NSLog(@"Portrait");
} else {
array = [[NSBundle mainBundle] loadNibNamed:@"Landscape" owner:self options:nil];
mainView = [array objectAtIndex:0];
NSLog(@"Landscape");
}
}
提前谢谢 试试这个谢谢你的链接,但我需要将编译器改为默认编译器(APPLE LLVM 5.0),(它会在将来产生问题吗?)此外,我认为它不会帮助我,因为它管理不同方向的布局,但我也必须更改一些元素。。我有什么选择吗?