Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.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 7方向仅在1个viewController中响应_Ios_Objective C - Fatal编程技术网

ios 7方向仅在1个viewController中响应

ios 7方向仅在1个viewController中响应,ios,objective-c,Ios,Objective C,我已取消选中蓝色文件中负责方向的复选框, 因为我不想让我的应用程序响应方向的变化,除了一个视图控制器,有可能让那个视图控制器响应方向吗 我见过一些类似的问题,但他们使用的是故事板,我没有使用它们。。。 是否有任何编程解决方案 viewController将显示modaly 我用这种方式调用viewController youtubePlayerViewController * yt = [[youtubePlayerViewController alloc]initWithYoutube

我已取消选中蓝色文件中负责方向的
复选框
, 因为我不想让我的应用程序响应方向的变化,除了一个视图控制器,有可能让那个视图控制器响应方向吗

我见过一些类似的问题,但他们使用的是故事板,我没有使用它们。。。 是否有任何编程解决方案

viewController
将显示
modaly

我用这种方式调用
viewController

    youtubePlayerViewController * yt = [[youtubePlayerViewController alloc]initWithYoutubeId:@"5d3zDO14PD0"];
    [self presentViewController:yt animated:YES completion:nil];
其中:

我尝试了很多东西,最后我试图强迫它回到横向方向,但它就是没有反应:(

但是,如果我允许蓝色文件中的复选框,它会起作用,但我的所有应用程序并不意味着只能在纵向模式下运行:-/

- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if (UIInterfaceOrientationIsLandscape(interfaceOrientation))
        return (YES);
    return (NO);
}

要支持多方向的类的子类UINavigationViewController,并在该类中添加

  // < iOS 6    
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation    {
        return UIInterfaceOrientationIsLandscape(toInterfaceOrientation);
     }

   // > iOS6
   - (BOOL)shouldAutorotate {
      return NO;
     }

   // > iOS6
    - (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskLandscape;
    }
/iOS6
-(BOOL)应该自动旋转{
返回否;
}
//>iOS6
-(整数)支持的接口方向{
返回UIInterfaceOrientationMaskLandscape;
}

1.如果您的rootView是UITabbarConroller,请将此代码添加到您的tabbar控制器中

 - (BOOL)shouldAutorotate
{
    return YES;
}

//only rotate in NeedRotateController
- (NSUInteger)supportedInterfaceOrientations
{
    UINavigationController * baseNavCtr = self.viewControllers[self.selectedIndex];
    if ([baseNavCtr.topViewController isKindOfClass:[NeedRotateController class]]) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }else {
        return UIInterfaceOrientationMaskPortrait;
    }
}
- (NSUInteger)supportedInterfaceOrientations
{
    if (self.topViewController isKindOfClass:[NeedRotateController class]) {
        return UIInterfaceOrientationPortraitUpsideDown;
    }else {
        return UIInterfaceOrientationPortrait;
    }
}

- (BOOL)shouldAutorotate {
    return YES;
}
2.如果rootView是UINavgationController

 - (BOOL)shouldAutorotate
{
    return YES;
}

//only rotate in NeedRotateController
- (NSUInteger)supportedInterfaceOrientations
{
    UINavigationController * baseNavCtr = self.viewControllers[self.selectedIndex];
    if ([baseNavCtr.topViewController isKindOfClass:[NeedRotateController class]]) {
        return UIInterfaceOrientationMaskAllButUpsideDown;
    }else {
        return UIInterfaceOrientationMaskPortrait;
    }
}
- (NSUInteger)supportedInterfaceOrientations
{
    if (self.topViewController isKindOfClass:[NeedRotateController class]) {
        return UIInterfaceOrientationPortraitUpsideDown;
    }else {
        return UIInterfaceOrientationPortrait;
    }
}

- (BOOL)shouldAutorotate {
    return YES;
}

3.如果这不起作用,请检查您的AppDelegate.m或info.plist支持旋转?

@Raptor编辑了问题不清楚,您想要什么?“蓝色文件”?您能检查我的答案吗:@mehulpatel inside Xcode IDE,“项目文件”它是蓝色的,很抱歉,我不知道它是如何调用的,但是有项目的所有首选项,而且方向在
general
部署中info@user3351949:如果要禁用特定视图控制器中的方向。请创建
UIViewController
的子类,然后在其中添加代码。然后只需把这个类转移到你不需要定向的视图控制器上。很抱歉我是个哑巴,但是关于
子类化
UINavigationViewController
,我应该添加新的文件来扩展
UINavigationViewController
->但是在里面放些什么呢?我的意思是它是如何工作的?如何工作我是否应该通过导航视图控制器调用我的
modalviewControlelr
?***由于未捕获的异常“UIApplicationInvalidInterfaceOrientation”而终止应用程序,原因是:“受支持的方向与应用程序没有共同的方向,并且shouldAutorotate返回YES'change/>iOS6-(BOOL)是否应自动旋转以返回“否”…而神秘的
需要旋转控制器
到底是什么?您的回答在当前上下文中没有任何意义。您想要响应方向的唯一视图控制器