Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 针对不同的方向加载不同的.xib_Ios_Objective C_Orientation_Nib - Fatal编程技术网

Ios 针对不同的方向加载不同的.xib

Ios 针对不同的方向加载不同的.xib,ios,objective-c,orientation,nib,Ios,Objective C,Orientation,Nib,在我的应用程序中,我想为不同的方向加载不同的.xib,即一个用于纵向,一个用于横向 我搜索了它,也找到了解决方案,但它对我不起作用。任何人都可以帮我解决这个问题 这是我的密码:- - (void)viewDidLoad { [super viewDidLoad]; [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications]; [[NSNotificationCenter defaultC

在我的应用程序中,我想为不同的方向加载不同的.xib,即一个用于纵向,一个用于横向

我搜索了它,也找到了解决方案,但它对我不起作用。任何人都可以帮我解决这个问题

这是我的密码:-

- (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),(它会在将来产生问题吗?)此外,我认为它不会帮助我,因为它管理不同方向的布局,但我也必须更改一些元素。。我有什么选择吗?