Ios 应用程序更改时将忽略我的方向

Ios 应用程序更改时将忽略我的方向,ios,objective-c,uiwebview,uiinterfaceorientation,Ios,Objective C,Uiwebview,Uiinterfaceorientation,我有个问题。我在这里解决了这个问题() 但是现在我的应用程序忽略了我的方向。如果我输入了登录数据并加载了新网站,但方向不同,则应用程序将忽略新的方向 dispatch_async(dispatch_get_main_queue(), ^{ NSNumber *value = [NSNumber alloc]; NSLog(@"Inside!"); NSLog(@"Orientation: %@", [self orientNr]);

我有个问题。我在这里解决了这个问题()

但是现在我的应用程序忽略了我的
方向。如果我输入了登录数据并加载了新网站,但
方向
不同,则应用程序将忽略新的
方向

dispatch_async(dispatch_get_main_queue(), ^{
    NSNumber *value = [NSNumber alloc];
    NSLog(@"Inside!");
    NSLog(@"Orientation: %@", [self orientNr]);
    if( [[self orientNr] isEqualToNumber:@1] ) value = [NSNumber numberWithInt:UIInterfaceOrientationUnknown];
    else if( [[self orientNr] isEqualToNumber:@2] ) value = [NSNumber numberWithInt:UIInterfaceOrientationLandscapeRight];
    else if( [[self orientNr] isEqualToNumber:@3] ) value = [NSNumber numberWithInt:UIInterfaceOrientationPortrait];
    [[UIDevice currentDevice] setValue:value forKey:@"orientation"];
});
应用程序正在进入这个区块,因为我在控制台上得到了两个日志。
方向是正确的,但不会执行

为什么应用程序会忽略我的
方向
?如果我重新启动应用程序,它总是纵向的,尽管它应该是横向的

编辑: 在我的文件plist.info中,我配置了支持的接口方向

编辑2: 我的代码看起来像


我已经在一个新项目中测试了您的代码,它可以正常工作。 如果正确配置了“支持的界面方向”条目,请查看info.plist:


还有另一种强制旋转的方法:

#import <objc/message.h>

嗨,我添加了我的info.plist的图像。我为iPad和iPhoneOk配置了它,然后我假设您的“orientNr”方法没有按预期工作;使用[[UIDevice currentDevice]设置值:[NSNumber Number Withint:UIInterfaceOrientationAndscapeRight]forKey:@“orientation”];我添加了两个图像。替换`[[UIDevice currentDevice]设置值:值forKey:@“方向”];`没有任何变化。我已经在一个新项目中测试了该代码,它可以正常工作。我编辑了我的答案,为你提供了另一种强制横向定位的方法
 ((void (*)(UIDevice *, SEL, int))objc_msgSend)([UIDevice currentDevice],@selector(setOrientation:),UIInterfaceOrientationLandscapeLeft);