Lock UIWebView orientation on iPhone

Is there a way to block the orientation of a UIWebView? With Obj-C, JS or Html? I don’t want to have a button or something that I just want it to be locked in the portrait as soon as the application opens.

+2
source share
1 answer

It looks like this post may indirectly answer your question. When the iPhone rotates, the “top-level” view is sent a notification, and this view is responsible for laying out its subzones.

If your UIWebView is a top-level view, it is automatically autorotated. However, if you place the UIWebView inside another view and the container controller has the shouldAutorateToInterfaceOrientation method for this view as the container:

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

This would probably prevent the UIWebView from knowing that the interface was rotated. Please note that I have not actually tried this, but it should work.

+3
source

Source: https://habr.com/ru/post/1309766/


All Articles