From 7df76fcd93fab8a9c7ffcfafb630fd7ff9cbfdde Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Mon, 28 May 2018 11:39:04 -0700 Subject: [PATCH] Allow the settings view to scroll on smaller iPhones --- .../ViewControllers/SettingsViewController.h | 1 + .../ViewControllers/SettingsViewController.m | 30 +++++++++++++++++-- iPhone.storyboard | 1 + 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/Limelight/ViewControllers/SettingsViewController.h b/Limelight/ViewControllers/SettingsViewController.h index 0b8499d..eee65ce 100644 --- a/Limelight/ViewControllers/SettingsViewController.h +++ b/Limelight/ViewControllers/SettingsViewController.h @@ -16,6 +16,7 @@ @property (strong, nonatomic) IBOutlet UISegmentedControl *resolutionSelector; @property (strong, nonatomic) IBOutlet UISegmentedControl *onscreenControlSelector; @property (strong, nonatomic) IBOutlet UISegmentedControl *remoteSelector; +@property (strong, nonatomic) IBOutlet UIScrollView *scrollView; - (void) saveSettings; diff --git a/Limelight/ViewControllers/SettingsViewController.m b/Limelight/ViewControllers/SettingsViewController.m index 272a655..56ccc79 100644 --- a/Limelight/ViewControllers/SettingsViewController.m +++ b/Limelight/ViewControllers/SettingsViewController.m @@ -18,9 +18,33 @@ } static NSString* bitrateFormat = @"Bitrate: %.1f Mbps"; -- (void)viewDidAppear:(BOOL)animated -{ - [super viewDidAppear:animated]; +-(void)viewDidLayoutSubviews { + // On iPhone layouts, this view is rooted at a ScrollView. To make it + // scrollable, we'll update content size here. + if (self.scrollView != nil) { + CGFloat highestViewY = 0; + + // Enumerate the scroll view's subviews looking for the + // highest view Y value to set our scroll view's content + // size. + for (UIView* view in self.scrollView.subviews) { + // UIScrollViews have 2 default UIImageView children + // which represent the horizontal and vertical scrolling + // indicators. Ignore these when computing content size. + if ([view isKindOfClass:[UIImageView class]]) { + continue; + } + + CGFloat currentViewY = view.frame.origin.y + view.frame.size.height; + if (currentViewY > highestViewY) { + highestViewY = currentViewY; + } + } + + // Add a bit of padding so the view doesn't end right at the button of the display + self.scrollView.contentSize = CGSizeMake(self.scrollView.contentSize.width, + highestViewY + 20); + } // Adjust the subviews for the safe area on the iPhone X. if (!_adjustedForSafeArea) { diff --git a/iPhone.storyboard b/iPhone.storyboard index 113a31f..e4c7306 100644 --- a/iPhone.storyboard +++ b/iPhone.storyboard @@ -185,6 +185,7 @@ +