Skip to content

Commit ca65bd7

Browse files
committed
Fix controllers not popping when pressing a tab bar button
1 parent 92d7ddc commit ca65bd7

File tree

3 files changed

+39
-2
lines changed

3 files changed

+39
-2
lines changed

trySwift.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
499CCFF21CC2E0F4007A5BBB /* UIViewControllerExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 499CCFF11CC2E0F4007A5BBB /* UIViewControllerExtension.swift */; };
2828
49F7B2811E8475F900F09768 /* SplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 49F7B2801E8475F900F09768 /* SplitViewController.swift */; };
2929
4D498DB1B98D4B496FDBB7AA /* Pods_try__Extension.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CD2E9D5733A6E1B6E10AFEEF /* Pods_try__Extension.framework */; };
30+
5C7F82DB2048B01D009193B4 /* RootTabBarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5C7F82DA2048B01D009193B4 /* RootTabBarController.swift */; };
3031
7AD1E19C80B78BB08E3DF079 /* Pods_trySwift.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 620220ABCCCDF47FDAF48B67 /* Pods_trySwift.framework */; };
3132
EAFE1C26E49EFABF83487BDC /* Pods_try__Today.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 24718BF11477753FCD47A7A8 /* Pods_try__Today.framework */; };
3233
FA0E2B4F1E63B90400B40814 /* SessionDetailInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA0E2B4E1E63B90400B40814 /* SessionDetailInterfaceController.swift */; };
@@ -193,6 +194,7 @@
193194
499CCFF11CC2E0F4007A5BBB /* UIViewControllerExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewControllerExtension.swift; sourceTree = "<group>"; };
194195
49F7B2801E8475F900F09768 /* SplitViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SplitViewController.swift; sourceTree = "<group>"; };
195196
58F81AD508535BD405F98215 /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
197+
5C7F82DA2048B01D009193B4 /* RootTabBarController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RootTabBarController.swift; sourceTree = "<group>"; };
196198
5FA07FBC036240AEF8B7C739 /* Pods-trySwift.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-trySwift.release.xcconfig"; path = "Pods/Target Support Files/Pods-trySwift/Pods-trySwift.release.xcconfig"; sourceTree = "<group>"; };
197199
620220ABCCCDF47FDAF48B67 /* Pods_trySwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_trySwift.framework; sourceTree = BUILT_PRODUCTS_DIR; };
198200
6C1F9C27BCD8099DCA758F7A /* CoreMedia.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMedia.framework; path = System/Library/Frameworks/CoreMedia.framework; sourceTree = SDKROOT; };
@@ -381,6 +383,14 @@
381383
name = Frameworks;
382384
sourceTree = "<group>";
383385
};
386+
5C7F82D92048B00B009193B4 /* RootTabBar */ = {
387+
isa = PBXGroup;
388+
children = (
389+
5C7F82DA2048B01D009193B4 /* RootTabBarController.swift */,
390+
);
391+
path = RootTabBar;
392+
sourceTree = "<group>";
393+
};
384394
F413680C9BA29129B4319377 /* Pods */ = {
385395
isa = PBXGroup;
386396
children = (
@@ -415,6 +425,7 @@
415425
FA39E8C51C6AB7310074B6BE /* ViewControllers */ = {
416426
isa = PBXGroup;
417427
children = (
428+
5C7F82D92048B00B009193B4 /* RootTabBar */,
418429
FA39E8FB1C6C26150074B6BE /* Schedule */,
419430
FA39E9061C6C43480074B6BE /* Speakers */,
420431
FABA73BF1D6D9ACE0081D887 /* OfficeHours */,
@@ -1124,6 +1135,7 @@
11241135
buildActionMask = 2147483647;
11251136
files = (
11261137
499BD62A1D05910200E74061 /* Twitter.swift in Sources */,
1138+
5C7F82DB2048B01D009193B4 /* RootTabBarController.swift in Sources */,
11271139
FA39E90F1C6C81870074B6BE /* SponsorsViewController.swift in Sources */,
11281140
FA36B7071E5DA3970022E6A9 /* DateFormatterExtension.swift in Sources */,
11291141
FAA54F141D9130F900EC9E80 /* UITableViewExtension.swift in Sources */,

trySwift/Base.lproj/Main.storyboard

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
1010
</dependencies>
1111
<scenes>
12-
<!--Tab Bar Controller-->
12+
<!--Root Tab Bar Controller-->
1313
<scene sceneID="mld-K4-cXp">
1414
<objects>
15-
<tabBarController id="Xe8-8h-xaI" sceneMemberID="viewController">
15+
<tabBarController id="Xe8-8h-xaI" customClass="RootTabBarController" customModule="trySwift" customModuleProvider="target" sceneMemberID="viewController">
1616
<tabBar key="tabBar" contentMode="scaleToFill" id="Iea-je-7kA">
1717
<rect key="frame" x="0.0" y="0.0" width="320" height="49"/>
1818
<autoresizingMask key="autoresizingMask"/>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//
2+
// RootTabBarController.swift
3+
// trySwift
4+
//
5+
// Created by Sash Zats on 3/2/18.
6+
// Copyright © 2018 NatashaTheRobot. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class RootTabBarController: UITabBarController, UITabBarControllerDelegate {
12+
override func viewDidLoad() {
13+
super.viewDidLoad()
14+
self.delegate = self
15+
}
16+
17+
func tabBarController(_ tabBarController: UITabBarController, didSelect viewController: UIViewController) {
18+
if let splitViewController = viewController as? UISplitViewController {
19+
if let navigationController = splitViewController.viewControllers.last as? UINavigationController,
20+
navigationController.viewControllers.count > 1 {
21+
navigationController.popViewController(animated: true)
22+
}
23+
}
24+
}
25+
}

0 commit comments

Comments
 (0)