Skip to content

Commit 07c9c97

Browse files
committed
still updating bk 2 ch 8
1 parent e8e89c7 commit 07c9c97

File tree

24 files changed

+90
-74
lines changed

24 files changed

+90
-74
lines changed

bk2ch06p281navigationInterface/ch19p615navigationInterface/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AppDelegate : UIResponder, UIApplicationDelegate {
4949
// UIGraphicsEndImageContext()
5050

5151
let im3 = im2.resizableImage(withCapInsets:UIEdgeInsets(top: 0,left: 0,bottom: 0,right: 0), resizingMode:.tile)
52-
UIBarButtonItem.appearance().setBackgroundImage(im3, for:[], barMetrics:.default)
52+
UIBarButtonItem.appearance().setBackgroundImage(im3, for:.normal, barMetrics:.default)
5353

5454

5555
// if the back button is assigned a background image, the chevron is removed entirely

bk2ch06p282navigationInterfaceStoryboard/ch19p615navigationInterface/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class AppDelegate : UIResponder, UIApplicationDelegate {
4848
// UIGraphicsEndImageContext()
4949

5050
let im3 = im2.resizableImage(withCapInsets:UIEdgeInsetsMake(0,0,0,0), resizingMode:.tile)
51-
UIBarButtonItem.appearance().setBackgroundImage(im3, for:[], barMetrics:.default)
51+
UIBarButtonItem.appearance().setBackgroundImage(im3, for:.normal, barMetrics:.default)
5252

5353

5454
// if the back button is assigned a background image, the chevron is removed entirely

bk2ch08p407addCellSubviewsInStoryboard/ch21p710addCellSubviewsInStoryboard/Base.lproj/Main.storyboard

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8187.4" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="7Yo-0I-mVs">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" colorMatched="YES" initialViewController="7Yo-0I-mVs">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8151.3"/>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
56
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
7+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
68
</dependencies>
79
<customFonts key="customFonts">
8-
<mutableArray key="Helvetica.ttc">
10+
<array key="Helvetica.ttc">
911
<string>Helvetica-Bold</string>
10-
</mutableArray>
12+
</array>
1113
</customFonts>
1214
<scenes>
1315
<!--Root View Controller-->
1416
<scene sceneID="QOB-kb-F8a">
1517
<objects>
1618
<tableViewController id="7Yo-0I-mVs" customClass="RootViewController" customModule="ch21p710addCellSubviewsInStoryboard" customModuleProvider="target" sceneMemberID="viewController">
1719
<tableView key="view" opaque="NO" clipsSubviews="YES" clearsContextBeforeDrawing="NO" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="58" sectionHeaderHeight="22" sectionFooterHeight="22" id="nyx-5s-Oig">
18-
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
20+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
1921
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
20-
<color key="backgroundColor" red="0.50076308140000003" green="1" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
22+
<color key="backgroundColor" red="0.50076308140000003" green="1" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
2123
<inset key="separatorInset" minX="15" minY="0.0" maxX="15" maxY="0.0"/>
2224
<prototypes>
2325
<tableViewCell contentMode="scaleToFill" selectionStyle="blue" hidesAccessoryWhenEditing="NO" indentationLevel="1" indentationWidth="0.0" reuseIdentifier="Cell" id="Ccj-6g-mfB" customClass="MyCell" customModule="ch21p710addCellSubviewsInStoryboard" customModuleProvider="target">
24-
<rect key="frame" x="0.0" y="22" width="320" height="58"/>
26+
<rect key="frame" x="0.0" y="22" width="375" height="58"/>
2527
<autoresizingMask key="autoresizingMask"/>
2628
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="Ccj-6g-mfB" id="7FJ-UK-ZPu">
27-
<rect key="frame" x="0.0" y="0.0" width="320" height="57"/>
29+
<frame key="frameInset" width="375" height="58"/>
2830
<autoresizingMask key="autoresizingMask"/>
2931
<subviews>
3032
<imageView userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="I1t-bX-Pco">
31-
<rect key="frame" x="248" y="0.0" width="57" height="57"/>
3233
<constraints>
3334
<constraint firstAttribute="width" secondItem="I1t-bX-Pco" secondAttribute="height" id="Z7e-KT-VOM"/>
3435
</constraints>
3536
</imageView>
3637
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Label" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" preferredMaxLayoutWidth="232" translatesAutoresizingMaskIntoConstraints="NO" id="ywb-cf-wVZ">
37-
<rect key="frame" x="15" y="0.0" width="218" height="57"/>
3838
<fontDescription key="fontDescription" name="Helvetica-Bold" family="Helvetica" pointSize="16"/>
3939
<nil key="highlightedColor"/>
4040
</label>
@@ -67,4 +67,9 @@
6767
<point key="canvasLocation" x="91" y="61"/>
6868
</scene>
6969
</scenes>
70+
<simulatedMetricsContainer key="defaultSimulatedMetrics">
71+
<simulatedStatusBarMetrics key="statusBar"/>
72+
<simulatedOrientationMetrics key="orientation"/>
73+
<simulatedScreenMetrics key="destination" type="retina4_7.fullscreen"/>
74+
</simulatedMetricsContainer>
7075
</document>

bk2ch08p412SimplestDataSource/SimplestDataSource/Base.lproj/Main.storyboard

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,29 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="8187.4" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="Vfx-D9-lVV">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G31" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Vfx-D9-lVV">
33
<dependencies>
4-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="8151.3"/>
4+
<deployment identifier="iOS"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11161"/>
6+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
57
</dependencies>
68
<scenes>
79
<!--Root View Controller-->
810
<scene sceneID="plh-fV-Twr">
911
<objects>
1012
<tableViewController automaticallyAdjustsScrollViewInsets="NO" id="sDu-Wi-YWc" customClass="RootViewController" customModule="Refresh" customModuleProvider="target" sceneMemberID="viewController">
1113
<tableView key="view" clipsSubviews="YES" contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="44" sectionHeaderHeight="22" sectionFooterHeight="22" id="flq-Sh-39t">
12-
<rect key="frame" x="0.0" y="64" width="600" height="536"/>
14+
<rect key="frame" x="0.0" y="64" width="375" height="603"/>
1315
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
14-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
16+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
1517
<prototypes>
1618
<tableViewCell contentMode="scaleToFill" selectionStyle="default" indentationWidth="10" reuseIdentifier="Cell" textLabel="Uit-kA-Iss" style="IBUITableViewCellStyleDefault" id="C6D-tj-8Du">
17-
<rect key="frame" x="0.0" y="22" width="600" height="44"/>
19+
<rect key="frame" x="0.0" y="22" width="375" height="44"/>
1820
<autoresizingMask key="autoresizingMask"/>
1921
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="C6D-tj-8Du" id="vvz-yg-TL7">
20-
<rect key="frame" x="0.0" y="0.0" width="600" height="43"/>
22+
<frame key="frameInset" width="375" height="44"/>
2123
<autoresizingMask key="autoresizingMask"/>
2224
<subviews>
2325
<label opaque="NO" multipleTouchEnabled="YES" contentMode="left" text="Title" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" id="Uit-kA-Iss">
24-
<rect key="frame" x="15" y="0.0" width="570" height="43"/>
26+
<frame key="frameInset" minX="15" width="345" height="43.5"/>
2527
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
2628
<fontDescription key="fontDescription" type="system" pointSize="16"/>
2729
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
@@ -45,12 +47,6 @@
4547
</connections>
4648
</barButtonItem>
4749
</navigationItem>
48-
<refreshControl key="refreshControl" opaque="NO" multipleTouchEnabled="YES" contentMode="center" enabled="NO" contentHorizontalAlignment="center" contentVerticalAlignment="center" id="T6r-e5-cBw">
49-
<autoresizingMask key="autoresizingMask"/>
50-
<connections>
51-
<action selector="doRefresh:" destination="sDu-Wi-YWc" eventType="valueChanged" id="Sw9-H0-wvm"/>
52-
</connections>
53-
</refreshControl>
5450
</tableViewController>
5551
<placeholder placeholderIdentifier="IBFirstResponder" id="z3U-VR-ZIG" userLabel="First Responder" sceneMemberID="firstResponder"/>
5652
</objects>

bk2ch08p412SimplestDataSource/SimplestDataSource/RootViewController.swift

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,26 @@ class RootViewController: UITableViewController {
3535

3636
override func viewDidLoad() {
3737
super.viewDidLoad()
38+
39+
// so this is still legal; you can give a tvc a refresh control in iOS 10
40+
// however, what's new is that this is _actually_ the table's refresh control
3841
// self.refreshControl = UIRefreshControl()
39-
// self.refreshControl!.addTarget(self, action: "doRefresh", forControlEvents: .ValueChanged)
42+
// self.refreshControl!.addTarget(self, action: #selector(doRefresh), for: .valueChanged)
43+
// print(self.tableView!.refreshControl)
44+
45+
// so you can write it like this instead:
46+
47+
self.tableView.refreshControl = UIRefreshControl()
48+
self.tableView.refreshControl!.addTarget(self, action: #selector(doRefresh), for: .valueChanged)
49+
50+
// moreover, when you do, your code just keeps on working;
51+
// this is also still the table view controller's refresh control!
4052

41-
// uncomment to show that the refresh control is hidden behind the background view
42-
// let v = UIView()
43-
// v.backgroundColor = .yellow
44-
// self.tableView.backgroundView = v
53+
// showing that the refresh control's background color covers the table's background
54+
let v = UIView()
55+
v.backgroundColor = .yellow
56+
self.tableView.backgroundView = v
57+
self.tableView.refreshControl?.backgroundColor = .green
4558
}
4659

4760
override func numberOfSections(in tableView: UITableView) -> Int {
@@ -71,6 +84,7 @@ class RootViewController: UITableViewController {
7184
}
7285

7386
@IBAction func doRefreshManually(_ sender: AnyObject) {
87+
// all this talk of `self.refreshControl` works, even though we didn't assign this way
7488
self.tableView.setContentOffset(
7589
CGPoint(0, -self.refreshControl!.bounds.height),
7690
animated:true)

bk2ch08p416sections/ch21p718sections/RootViewController.swift

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ class RootViewController : UITableViewController {
6868
// this is more "interesting"
6969
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
7070
let h = tableView.dequeueReusableHeaderFooterView(withIdentifier:"Header")!
71-
if h.tintColor != .red {
72-
print("configuring a new header view") // only called about 7 times
73-
h.tintColor = .red // invisible marker, tee-hee
71+
if h.viewWithTag(1) == nil {
72+
print("configuring a new header view") // only called about 8 times
73+
7474
h.backgroundView = UIView()
7575
h.backgroundView?.backgroundColor = .black
7676
let lab = UILabel()
@@ -96,14 +96,15 @@ class RootViewController : UITableViewController {
9696
].flatMap{$0})
9797

9898
// uncomment to see bug where button does not inherit superview's tint color
99-
// let b = UIButton(type:.System)
100-
// b.setTitle("Howdy", for:[])
99+
// let b = UIButton(type:.system)
100+
// b.setTitle("Howdy", for:.normal)
101101
// b.sizeToFit()
102102
// print(b.tintColor)
103103
// h.addSubview(b)
104104
}
105105
let lab = h.contentView.viewWithTag(1) as! UILabel
106106
lab.text = self.sectionNames[section]
107+
// print(h.backgroundView?.backgroundColor)
107108
return h
108109

109110
}

bk2ch08p438searchableTable/ch21p718sections/RootViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
108108
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
109109
let h = tableView
110110
.dequeueReusableHeaderFooterView(withIdentifier:"Header")!
111-
if h.tintColor != .red {
112-
h.tintColor = .red // invisible marker, tee-hee
111+
if h.viewWithTag(1) == nil {
112+
113113
h.backgroundView = UIView()
114114
h.backgroundView?.backgroundColor = .black
115115
let lab = UILabel()

bk2ch08p438searchableTable2/ch21p718sections/RootViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
8989
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
9090
let h = tableView
9191
.dequeueReusableHeaderFooterView(withIdentifier:"Header")!
92-
if h.tintColor != .red {
93-
h.tintColor = .red // invisible marker, tee-hee
92+
if h.viewWithTag(1) == nil {
93+
9494
h.backgroundView = UIView()
9595
h.backgroundView?.backgroundColor = .black
9696
let lab = UILabel()

bk2ch08p438searchableTable3/ch21p718sections/RootViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
101101
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
102102
let h = tableView
103103
.dequeueReusableHeaderFooterView(withIdentifier:"Header")!
104-
if h.tintColor != .red {
105-
h.tintColor = .red // invisible marker, tee-hee
104+
if h.viewWithTag(1) == nil {
105+
106106
h.backgroundView = UIView()
107107
h.backgroundView?.backgroundColor = .black
108108
let lab = UILabel()

bk2ch08p438searchableTable4/ch21p718sections/RootViewController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,8 +97,8 @@ class RootViewController : UITableViewController, UISearchBarDelegate {
9797
override func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
9898
let h = tableView
9999
.dequeueReusableHeaderFooterView(withIdentifier:"Header")!
100-
if h.tintColor != .red {
101-
h.tintColor = .red // invisible marker, tee-hee
100+
if h.viewWithTag(1) == nil {
101+
102102
h.backgroundView = UIView()
103103
h.backgroundView?.backgroundColor = .black
104104
let lab = UILabel()

0 commit comments

Comments
 (0)