自定义Segue肖像模式

时间:2013-08-25 02:45:44

标签: iphone ios

我正在尝试创建一个自定义segue来更改并将我的下一个视图锁定为纵向模式,无论设备如何旋转。我能够创建我的UIStoryBoardSegue文件,但现在我坚持使用代码从横向切换到肖像......这是我到目前为止所做的:

-(void) perform

{
        self.appDelegate = [[UIApplication sharedApplication] delegate];
        UIViewController *source = (UIViewController *) self.sourceViewController;
        UIViewController *destination = (UIViewController *) self.destinationViewController;



    }

现在我被困了......帮忙!

2 个答案:

答案 0 :(得分:0)

一种方法是重载视图控制器子类的supportedDeviceOrientations方法,如此

- (NSUInteger)supportedInterfaceOrientations {
    return UIDeviceOrientationPortrait;
}

答案 1 :(得分:0)

我不知道你是在为iOS 6或iOS 6写作,但如果它是iOS 6,请尝试将以下代码放在你试图设置其方向的视图控制器中。

- (BOOL) shouldAutorotate
{
return YES;
}

-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskLandscapeRight | UIInterfaceOrientationMaskLandscapeLeft   | UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown;
}

现在上面的方法包含了所有蒙版,您可以删除不需要的蒙版。实际上不再需要访问应用程序代理进行轮换设置。希望这可以帮助您实现您想要的目标。

相关问题