Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/apache-kafka/3.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界面生成器中使用故事板支持横向和纵向_Ios_Storyboard_Landscape Portrait - Fatal编程技术网

在iOS界面生成器中使用故事板支持横向和纵向

在iOS界面生成器中使用故事板支持横向和纵向,ios,storyboard,landscape-portrait,Ios,Storyboard,Landscape Portrait,我开发了一个应用程序,支持纵向和横向与GPOrientationKit的方向。我按照下面的链接做了应用程序的所有页面,以支持这两个方向 我用XIB或NIB文件做了那个应用程序。现在,我正在开发一个带有故事板的应用程序。我不知道如何做的应用程序,支持这两个方向的故事板。GPOrientationKit对于XIB文件很有效。但我正在与故事板抗争。我需要像GPOrientationKit这样的功能。请帮我做那件事 提前谢谢 点击项目>选择目标>常规设置设备方向。只需在控制器的主视图中添加两个子视图,

我开发了一个应用程序,支持纵向和横向与GPOrientationKit的方向。我按照下面的链接做了应用程序的所有页面,以支持这两个方向

我用XIB或NIB文件做了那个应用程序。现在,我正在开发一个带有故事板的应用程序。我不知道如何做的应用程序,支持这两个方向的故事板。GPOrientationKit对于XIB文件很有效。但我正在与故事板抗争。我需要像GPOrientationKit这样的功能。请帮我做那件事


提前谢谢

点击项目>选择目标>常规设置设备方向。

只需在控制器的主视图中添加两个子视图,如纵向视图和横向视图,并在方向改变时在它们之间切换。.我有类似的想法

在您的ViewWillDisplay方法中添加以下内容

-(void)viewDidAppear:(BOOL)animated{

        if(UIDeviceOrientationIsPortrait(self.interfaceOrientation))
    {

//Keep LAndscape View Hidden
    self.portraitVIew.frame=self.view.frame;
    [self.view addSubview:self.portraitVIew];
    }else{


//Keep portrait View Hidden

    self.landscapeView.frame=self.view.frame;
    [self.view addSubview:self.landscapeView];
    }
    self.view.autoresizesSubviews = YES;

     } 
    [[NSNotificationCenter defaultCenter]
     addObserver:self
     selector:@selector(deviceOrientationDidChangeNotification:)
     name:UIDeviceOrientationDidChangeNotification
     object:nil];



}
然后实现方法DeviceOrientationIDChangeNotification,例如

- (void)deviceOrientationDidChangeNotification:(NSNotification*)note
{


        UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
        if(UIDeviceOrientationIsLandscape(self.interfaceOrientation))
        {
//Keep portrait View Hidden

            NSLog(@"YUP THIS IS LANDSCAPE");
            self.landscapeView.hidden=NO;
            self.landscapeView.frame=self.view.frame;
            [self.portraitVIew removeFromSuperview];
            ///self.landscapeView.frame=CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height);


            [self.view addSubview:self.landscapeView];
        }else {
//Keep LAndscape View Hidden

            self.landscapeView.hidden=YES;
            self.portraitVIew.frame=self.view.frame;
            NSLog(@"Portrait");

            [self.view addSubview:self.portraitVIew];
        }
}