iphone: Forcefully change orientation from portrait to landscape on navigation

前端 未结 3 1264
名媛妹妹
名媛妹妹 2021-01-06 16:07

Is there any way that we can Forcefully change app orientation from portrait to landscape while navigating ?

I have a requirement that while pushing controller from

3条回答
  •  余生分开走
    2021-01-06 17:02

    from my experience on the last app in which I tried doing the same, I found answers on Stack overflow telling not to forcibly change the orientation in a Navigation based application.

    (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
     if(interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
            return NO;
    else
        return YES;
    }
    

    this function will let you use the view controller in the desired orientation, in this case I've set it for landscape, and disallowed rotation in portrait modes.

    You will face the problem of the B view controller loading first in the orientation on A view controller thou. So I changed the full orientation of the app to landscape. Hope this helps.

提交回复
热议问题