Skip to content

Commit 0b03f8d

Browse files
committed
Fix large title behavior
scroll far enough to the top to ensure the large title is displayed; configure the sample app to use large titles in some of the examples;
1 parent 4bb27d8 commit 0b03f8d

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed

InAppSettingsKitSampleApp/Base.lproj/Main.storyboard

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="22113.3" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="3Gr-jG-lyL">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="24112" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="3Gr-jG-lyL">
33
<device id="retina6_1" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22089.1"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="24057"/>
77
<capability name="System colors in document resources" minToolsVersion="11.0"/>
88
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
99
</dependencies>
@@ -12,7 +12,7 @@
1212
<scene sceneID="Zt4-yV-Tva">
1313
<objects>
1414
<tableViewController id="3Zf-yv-ugt" customClass="IASKAppSettingsViewController" sceneMemberID="viewController">
15-
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="443-2y-GSG">
15+
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" alwaysBounceVertical="YES" dataMode="prototypes" style="grouped" separatorStyle="default" rowHeight="-1" estimatedRowHeight="-1" sectionHeaderHeight="18" sectionFooterHeight="18" id="443-2y-GSG">
1616
<rect key="frame" x="0.0" y="0.0" width="450" height="450"/>
1717
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1818
<color key="backgroundColor" systemColor="groupTableViewBackgroundColor"/>
@@ -37,8 +37,8 @@
3737
<tabBarItem key="tabBarItem" title="Settings" image="20-gear2.png" id="n11-vj-bkV"/>
3838
<value key="contentSizeForViewInPopover" type="size" width="450" height="450"/>
3939
<size key="freeformSize" width="450" height="450"/>
40-
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="Fgk-j7-eRM">
41-
<rect key="frame" x="0.0" y="0.0" width="450" height="44"/>
40+
<navigationBar key="navigationBar" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="Fgk-j7-eRM">
41+
<rect key="frame" x="0.0" y="48" width="450" height="54"/>
4242
<autoresizingMask key="autoresizingMask"/>
4343
</navigationBar>
4444
<connections>
@@ -57,7 +57,7 @@
5757
<viewControllerLayoutGuide type="top" id="aex-PX-YAG"/>
5858
<viewControllerLayoutGuide type="bottom" id="1lu-Kk-k54"/>
5959
</layoutGuides>
60-
<view key="view" contentMode="scaleToFill" id="3VK-Jj-4Bv">
60+
<view key="view" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="3VK-Jj-4Bv">
6161
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
6262
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
6363
<subviews>
@@ -78,7 +78,7 @@
7878
<color key="titleShadowColor" red="0.5" green="0.5" blue="0.5" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
7979
</state>
8080
<connections>
81-
<segue destination="S2w-zu-zJk" kind="presentation" identifier="modal" id="EaZ-im-nY2"/>
81+
<segue destination="S2w-zu-zJk" kind="presentation" identifier="modal" modalPresentationStyle="pageSheet" id="EaZ-im-nY2"/>
8282
</connections>
8383
</button>
8484
</subviews>
@@ -130,8 +130,8 @@
130130
<objects>
131131
<navigationController id="BHR-vT-tkQ" sceneMemberID="viewController">
132132
<tabBarItem key="tabBarItem" selectedImage="20-gear2.png" systemItem="featured" id="cIz-OH-P5r"/>
133-
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="73K-t4-ygZ">
134-
<rect key="frame" x="0.0" y="48" width="414" height="44"/>
133+
<navigationBar key="navigationBar" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" largeTitles="YES" id="73K-t4-ygZ">
134+
<rect key="frame" x="0.0" y="96" width="414" height="106"/>
135135
<autoresizingMask key="autoresizingMask"/>
136136
</navigationBar>
137137
<connections>
@@ -149,8 +149,8 @@
149149
<tabBarItem key="tabBarItem" selectedImage="20-gear2.png" systemItem="featured" id="Gb4-Mn-Ir9"/>
150150
<navigationItem key="navigationItem" id="OmC-Fw-Chl"/>
151151
<value key="contentSizeForViewInPopover" type="size" width="450" height="450"/>
152-
<navigationBar key="navigationBar" contentMode="scaleToFill" insetsLayoutMarginsFromSafeArea="NO" id="LLy-AZ-C3h">
153-
<rect key="frame" x="0.0" y="0.0" width="450" height="44"/>
152+
<navigationBar key="navigationBar" contentMode="scaleToFill" preservesSuperviewLayoutMargins="YES" id="LLy-AZ-C3h">
153+
<rect key="frame" x="0.0" y="48" width="450" height="54"/>
154154
<autoresizingMask key="autoresizingMask"/>
155155
</navigationBar>
156156
<connections>

InAppSettingsKitSampleApp/Classes/MainViewController.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ class MainViewController: UIViewController {
3737
let settingsVC = nc.topViewController as? IASKAppSettingsViewController
3838
{
3939
settingsVC.delegate = self
40-
settingsVC.showDoneButton = segue.identifier == "modal"
40+
settingsVC.showDoneButton = true
4141
settingsVC.colorScheme = .tinted
42+
nc.navigationBar.prefersLargeTitles = segue.identifier == "modal"
4243
settingsViewController = settingsVC
43-
} else if let settingsVC = segue.destination as? IASKAppSettingsViewController{
44+
} else if let settingsVC = segue.destination as? IASKAppSettingsViewController {
4445
settingsVC.delegate = self
4546
settingsViewController = settingsVC
4647
} else {

Sources/InAppSettingsKit/Controllers/IASKAppSettingsViewController.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ - (void)viewWillAppear:(BOOL)animated {
229229
dispatch_async(dispatch_get_main_queue(), ^(void){
230230
[self.tableView selectRowAtIndexPath:selectedIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
231231
});
232+
} else if (self.navigationController.navigationBar.prefersLargeTitles) {
233+
// -200 is large enough to show the large title if configured.
234+
// UIKit is clever enough to clamp the offset to the maximum possible value.
235+
self.tableView.contentOffset = CGPointMake(0, -200);
232236
}
233237

234238
NSNotificationCenter *dc = NSNotificationCenter.defaultCenter;

0 commit comments

Comments
 (0)