سؤال

I have storyboard project in xcode. Most scene is show in portrait orientation but I want to show one of scene in landscape mode without user rotate the device, always this scene is shown it must be in landscape. This scene has a simple viewcontroller with uiwebview object wich I open a pdf file from url. My idea is show the viewcontroller as a modal viewcontroller.

Anyone known how solve this issue?, yesterday I spend my time searching about this in Internet but I don't find out a solution.

Thank you in advance!

هل كانت مفيدة؟

المحلول

How the scene is actually displayed is not determined by the storyboard but rather the viewcontroller. You need to create an UIViewController subclass and implement - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation to return YES only if the interface orientation is a landscape orientation. You could do it like this:

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

to allow both orientations or replace with

return interfaceOrientation == UIInterfaceOrientationLandscapeLeft

to allow only one direction.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top