Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How lock screen in iOS for it to have only portrait orientation?

I have created an app with many views and I want to have some of them only in portrait orientation. I have coded this in .m file:

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

Do I need to do something else? May be in .h file?

like image 638
Ash Var Avatar asked Dec 15 '22 21:12

Ash Var


1 Answers

Cleanest solution for me:

Go to Info.plist file and for the "Supported interface orientations", remove every value except "Portrait (bottom home button)".

like image 158
da Rocha Pires Avatar answered Apr 22 '23 09:04

da Rocha Pires