Skip to content

Commit 94df497

Browse files
authored
Merge pull request #118 from dakeshi/fix_uidemo
Fix uidemo error and refactoring codes about UIStoryboard
2 parents ea3e62a + 7783ff3 commit 94df497

File tree

6 files changed

+32
-18
lines changed

6 files changed

+32
-18
lines changed

samples/swift/uidemo.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
objects = {
88

99
/* Begin PBXBuildFile section */
10+
574F1B131D8106D2001924BB /* UIStoryboardExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 574F1B121D8106D2001924BB /* UIStoryboardExtension.swift */; };
1011
8D16073E1D492B200069E4F5 /* AuthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8D16073D1D492B200069E4F5 /* AuthViewController.swift */; };
1112
8DABC9891D3D82D600453807 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DABC9881D3D82D600453807 /* AppDelegate.swift */; };
1213
8DABC98B1D3D82D600453807 /* MenuViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8DABC98A1D3D82D600453807 /* MenuViewController.swift */; };
@@ -31,6 +32,7 @@
3132
/* End PBXContainerItemProxy section */
3233

3334
/* Begin PBXFileReference section */
35+
574F1B121D8106D2001924BB /* UIStoryboardExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIStoryboardExtension.swift; sourceTree = "<group>"; };
3436
8D16073D1D492B200069E4F5 /* AuthViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AuthViewController.swift; sourceTree = "<group>"; };
3537
8DABC9851D3D82D600453807 /* uidemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = uidemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
3638
8DABC9881D3D82D600453807 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
@@ -100,6 +102,7 @@
100102
8DABC98A1D3D82D600453807 /* MenuViewController.swift */,
101103
8DABC9AA1D3D947300453807 /* SampleCell.swift */,
102104
8DABC9A81D3D872C00453807 /* Sample.swift */,
105+
574F1B121D8106D2001924BB /* UIStoryboardExtension.swift */,
103106
8DD17C951D4BCC6500E850E4 /* AuthSample */,
104107
8D643F0F1D4827F10081F979 /* ChatSample */,
105108
8DABC98C1D3D82D600453807 /* Main.storyboard */,
@@ -329,6 +332,7 @@
329332
files = (
330333
8DABC98B1D3D82D600453807 /* MenuViewController.swift in Sources */,
331334
8DABC9AB1D3D947300453807 /* SampleCell.swift in Sources */,
335+
574F1B131D8106D2001924BB /* UIStoryboardExtension.swift in Sources */,
332336
8DABC9A91D3D872C00453807 /* Sample.swift in Sources */,
333337
8D16073E1D492B200069E4F5 /* AuthViewController.swift in Sources */,
334338
8DABC9AD1D3D9EAF00453807 /* ChatViewController.swift in Sources */,

samples/swift/uidemo/AppDelegate.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,10 @@
1616

1717
import UIKit
1818
import Firebase
19-
import FirebaseAuthUI.FIRAuthUI
19+
import FirebaseAuthUI
2020

2121
@UIApplicationMain
2222
class AppDelegate: UIResponder, UIApplicationDelegate {
23-
24-
static var mainStoryboard: UIStoryboard {
25-
return UIStoryboard(name: "Main", bundle: nil)
26-
}
2723

2824
var window: UIWindow?
2925

samples/swift/uidemo/AuthViewController.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,5 @@ class AuthViewController: UIViewController {
118118
override func viewWillLayoutSubviews() {
119119
self.topConstraint.constant = self.topLayoutGuide.length
120120
}
121-
122-
static func fromStoryboard(storyboard: UIStoryboard = AppDelegate.mainStoryboard) -> AuthViewController {
123-
return storyboard.instantiateViewControllerWithIdentifier("AuthViewController") as! AuthViewController
124-
}
121+
125122
}

samples/swift/uidemo/ChatViewController.swift

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,7 @@ class ChatViewController: UIViewController, UICollectionViewDelegateFlowLayout {
128128

129129
self.textView.text = ""
130130
}
131-
132-
// MARK: - Boilerplate
133-
134-
static func fromStoryboard(storyboard: UIStoryboard = AppDelegate.mainStoryboard) -> ChatViewController {
135-
return storyboard.instantiateViewControllerWithIdentifier("ChatViewController") as! ChatViewController
136-
}
137-
131+
138132
override func viewDidLoad() {
139133
super.viewDidLoad()
140134

samples/swift/uidemo/Sample.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ enum Sample: Int, RawRepresentable {
5252
func controller() -> UIViewController {
5353
switch self {
5454
case .Chat:
55-
return ChatViewController.fromStoryboard()
55+
return UIStoryboard.instantiateViewController("Main", identifier: "ChatViewController") as! ChatViewController
5656
case .Auth:
57-
return AuthViewController.fromStoryboard()
57+
return UIStoryboard.instantiateViewController("Main", identifier: "AuthViewController") as! AuthViewController
5858
}
5959
}
6060
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
//
2+
// Copyright (c) 2016 Google Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
//
16+
17+
import UIKit
18+
19+
extension UIStoryboard {
20+
static func instantiateViewController(storyboard: String, identifier: String) -> UIViewController {
21+
return UIStoryboard(name: storyboard, bundle: nil).instantiateViewControllerWithIdentifier(identifier)
22+
}
23+
}

0 commit comments

Comments
 (0)