How to make only a subtitle landscape?

I know that there is one question: Only the ONE TYPE mode of the landscape , and I carefully read it before asking about it.

I have a WKWebview named as webview in my application and the webview has a subtitle named as a player. I used web browsing to load a webpage and a player to play videos.

By default, the player shrinks to the bottom right of the web browser, and I want to expand the player to landscape when I click the β€œExpand” button for the player.

Since web browsing and the player do not work in WebViewController.swift, this indicates the same controller. How can I just approach the landscape of the player?

+5
source share
3 answers

You can try with several UIWindow . Each UIWindow can have its own root view controller. Thus, it is possible that one window rotates and the other does not. I myself used this approach, and it worked very well for me. It can be very difficult to make your subview an independent UIWindow , but I think it's worth a try. Hope this information helps.

+6
source

From my point of view, it is not possible to set only one orientation for a subview in an application. The view controller can have only one orientation (landscape / portrait)

You can put a dummy video controller to the right from the bottom of the screen and above that, you can put a button or something else (tappable object). When you click on a button or a custom object, you can introduce a new viewing controller in which you can play video only in landscape mode.

After the video has finished playing, you can turn off the view controller.

+3
source

You can check the class when your application receives a change of orientation request, as shown below.

 #pragma mark - Orientations Methods - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { if ([[self.window.rootViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]]) { return UIInterfaceOrientationMaskAllButUpsideDown; } else { if ([[self.window.rootViewController presentedViewController] isKindOfClass:[UINavigationController class]]) { // look for it inside UINavigationController UINavigationController *nc = (UINavigationController *)[self.window.rootViewController presentedViewController]; // is at the top? if ([nc.topViewController isKindOfClass:[MPMoviePlayerViewController class]]) { return UIInterfaceOrientationMaskAllButUpsideDown; // or it presented from the top? } else if ([[nc.topViewController presentedViewController] isKindOfClass:[MPMoviePlayerViewController class]]) { return UIInterfaceOrientationMaskAllButUpsideDown; } } } return UIInterfaceOrientationMaskPortrait; } 

This method will verify that if your class is a movie player, it allows you to rotate your image. You must be contacted when the user clicks the end button in the movie player

+2
source

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


All Articles