Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/39.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
Iphone 应用程序没有';不要改变方向_Iphone_Objective C_Orientation_Screen Orientation - Fatal编程技术网

Iphone 应用程序没有';不要改变方向

Iphone 应用程序没有';不要改变方向,iphone,objective-c,orientation,screen-orientation,Iphone,Objective C,Orientation,Screen Orientation,我有一个带有tabbar的应用程序,我想在其中检测接口方向 我已经在info.plist中设置了支持的方向。 这是我的主界面声明: @interface MyAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { ... } 在我试图检测方向变化的必要视图中,我调用以下方法: - (void)willRotateToInterfaceOrientation:(UIInterfac

我有一个带有tabbar的应用程序,我想在其中检测接口方向

我已经在info.plist中设置了支持的方向。 这是我的主界面声明:

@interface MyAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> {
   ...
}
在我试图检测方向变化的必要视图中,我调用以下方法:

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration;

我在这些方法中设置了NSLog打印,但没有一个方法记录任何更改。甚至在shouldAutorotateToInterfaceOrientation方法中也没有

有人能帮我吗?我做错了什么?
任何帮助都将不胜感激。

应自动旋转指针界面方向:
是您必须在视图控制器中实现的方法,而不是在应用程序代理中实现。对于要旋转的选项卡栏应用程序,选项卡栏控制器的所有子控制器必须针对请求的界面方向返回
YES

类似地,
将在视图控制器中实现RotateToInterfaceOrientation:
didRotateFromInterfaceOrientation:
,而不是像您所说的那样在视图中实现

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 

方法必须在viewController中实现,而不是在appdelegate中实现。谢谢,Ole Begemann。应在所有视图控制器中实现shouldAutorotateToInterfaceOrientation方法,以使方向正常工作。我让它工作了。但现在的问题是,所有的标签都在旋转(我有3个),我只需要旋转第二个。如果你帮我做这件事,你会得到一杯啤酒:)无论如何,再次谢谢你。帮了我很多忙!根据当前可见的选项卡,尝试从该方法返回
YES
NO
(在所有视图控制器中)。
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation;
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation