From 00d89f12e8227589d6faefca9c91b0181511475d Mon Sep 17 00:00:00 2001 From: True Zhuanjia Date: Fri, 12 Jul 2024 22:48:53 +0800 Subject: [PATCH] correct landscape host view well device sensor is portrait --- .../ViewControllers/MainFrameViewController.m | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index 03860526..79ae186c 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -1014,9 +1014,8 @@ static NSMutableSet* hostList; - (void)viewDidLoad { - //[OrientationHelper updateOrientationToLandscape]; - [super viewDidLoad]; + //[OrientationHelper updateOrientationToLandscape]; [self attachWaterMark]; #if !TARGET_OS_TV _settingsExpandedInStreamView = false; // init this flag @@ -1076,7 +1075,21 @@ static NSMutableSet* hostList; _boxArtCache = [[NSCache alloc] init]; hostScrollView = [[ComputerScrollView alloc] init]; - hostScrollView.frame = CGRectMake(0, self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height, self.view.frame.size.width, self.view.frame.size.height / 2); + + CGFloat screenWidthInPoints = CGRectGetWidth([[UIScreen mainScreen] bounds]); + CGFloat screenHeightInPoints = CGRectGetHeight([[UIScreen mainScreen] bounds]); + + bool isLandscape = screenWidthInPoints > screenHeightInPoints; + NSLog(@"isLandscape1 %d", isLandscape); + CGFloat realViewFrameWidth = self.view.frame.size.width > self.view.frame.size.height ? self.view.frame.size.width : self.view.frame.size.height; + CGFloat realViewFrameHeight = self.view.frame.size.width < self.view.frame.size.height ? self.view.frame.size.width : self.view.frame.size.height; + if(!isLandscape) { + CGFloat tmpLength = realViewFrameWidth; + realViewFrameWidth = realViewFrameHeight; + realViewFrameHeight = tmpLength; + } + + hostScrollView.frame = CGRectMake(0, self.navigationController.navigationBar.frame.origin.y + self.navigationController.navigationBar.frame.size.height, realViewFrameWidth, realViewFrameHeight / 2); [hostScrollView setShowsHorizontalScrollIndicator:NO]; hostScrollView.delaysContentTouches = NO;