From b28bc6787bb71908a3329b63d8f7e50ce14e49d0 Mon Sep 17 00:00:00 2001 From: kevinzhow Date: Sat, 23 May 2015 00:23:07 +0800 Subject: [PATCH] Fix a skillhome bug on navigation bar --- Yep.xcodeproj/project.pbxproj | 12 ++++ .../Base/BaseViewController.swift | 55 +++++++++++++++++++ .../ConversationViewController.swift | 2 +- .../CustomNavigationBarViewController.swift | 20 ------- 4 files changed, 68 insertions(+), 21 deletions(-) create mode 100644 Yep/ViewControllers/Base/BaseViewController.swift diff --git a/Yep.xcodeproj/project.pbxproj b/Yep.xcodeproj/project.pbxproj index 3b69a719..b8483f74 100644 --- a/Yep.xcodeproj/project.pbxproj +++ b/Yep.xcodeproj/project.pbxproj @@ -27,6 +27,7 @@ 0A90187F1B01152800AE4B7F /* ProfileSocialAccountCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0A90187D1B01152800AE4B7F /* ProfileSocialAccountCell.xib */; }; 0A9018821B0120A500AE4B7F /* OAuthViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A9018811B0120A500AE4B7F /* OAuthViewController.swift */; }; 0A9018871B01321F00AE4B7F /* WebViewJavascriptBridge.js.txt in Resources */ = {isa = PBXBuildFile; fileRef = 0A9018861B01321F00AE4B7F /* WebViewJavascriptBridge.js.txt */; }; + 0A943A7B1B0F8EAE0022DD67 /* BaseViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A943A7A1B0F8EAE0022DD67 /* BaseViewController.swift */; }; 0A944C251AC8BB2F00037A06 /* YepStorageService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A944C241AC8BB2F00037A06 /* YepStorageService.swift */; }; 0AAFCFF91AC8CA5B00EB0EF8 /* MobileCoreServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AAFCFF81AC8CA5B00EB0EF8 /* MobileCoreServices.framework */; }; 0AD7EA5E1AC3ED1200617758 /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0AD7EA5D1AC3ED1200617758 /* CFNetwork.framework */; }; @@ -226,6 +227,7 @@ 0A90187D1B01152800AE4B7F /* ProfileSocialAccountCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = ProfileSocialAccountCell.xib; path = Views/Cells/ProfileSocialAccount/ProfileSocialAccountCell.xib; sourceTree = ""; }; 0A9018811B0120A500AE4B7F /* OAuthViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OAuthViewController.swift; path = ViewControllers/OAuth/OAuthViewController.swift; sourceTree = ""; }; 0A9018861B01321F00AE4B7F /* WebViewJavascriptBridge.js.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = WebViewJavascriptBridge.js.txt; sourceTree = ""; }; + 0A943A7A1B0F8EAE0022DD67 /* BaseViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BaseViewController.swift; path = ViewControllers/Base/BaseViewController.swift; sourceTree = ""; }; 0A944C241AC8BB2F00037A06 /* YepStorageService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = YepStorageService.swift; path = Services/YepStorageService.swift; sourceTree = ""; }; 0AAFCFF81AC8CA5B00EB0EF8 /* MobileCoreServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MobileCoreServices.framework; path = System/Library/Frameworks/MobileCoreServices.framework; sourceTree = SDKROOT; }; 0AD7EA511AC3EA6F00617758 /* JPushSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JPushSDK.framework; path = "Pods/../build/Debug-iphoneos/Pods/JPushSDK.framework"; sourceTree = ""; }; @@ -576,6 +578,14 @@ name = WebViewJSBridge; sourceTree = ""; }; + 0A943A7C1B0F8EB10022DD67 /* Base */ = { + isa = PBXGroup; + children = ( + 0A943A7A1B0F8EAE0022DD67 /* BaseViewController.swift */, + ); + name = Base; + sourceTree = ""; + }; 0AD7EA751AC3EE9B00617758 /* JPush */ = { isa = PBXGroup; children = ( @@ -617,6 +627,7 @@ 508F8FCD1B01C80500461B0B /* SocialWorks */, 5064F6511B0AE2ED0089FAD4 /* AddFriends */, 502048251B0F1BB8002EBFC7 /* SearchedUsers */, + 0A943A7C1B0F8EB10022DD67 /* Base */, ); name = ViewControllers; sourceTree = ""; @@ -1583,6 +1594,7 @@ 50E114F41ABBF9CC00F13000 /* Models.swift in Sources */, 5053AD551AF83B0F00B3CBFA /* ChatRightLocationCell.swift in Sources */, 50A9D4571ACD393A000B2599 /* YepWaverView.swift in Sources */, + 0A943A7B1B0F8EAE0022DD67 /* BaseViewController.swift in Sources */, 50165C451AC2860900C7AEBE /* ConversationLayout.swift in Sources */, 50EB8C5E1AE78AB9001AC1EE /* YepAsset.swift in Sources */, 508C2AA41AD661B3002B8097 /* UserStateCell.swift in Sources */, diff --git a/Yep/ViewControllers/Base/BaseViewController.swift b/Yep/ViewControllers/Base/BaseViewController.swift new file mode 100644 index 00000000..6c3f2c28 --- /dev/null +++ b/Yep/ViewControllers/Base/BaseViewController.swift @@ -0,0 +1,55 @@ +// +// BaseViewController.swift +// Yep +// +// Created by kevinzhow on 15/5/23. +// Copyright (c) 2015年 Catch Inc. All rights reserved. +// + +import UIKit + +class BaseViewController: UIViewController { + + override func viewDidLoad() { + super.viewDidLoad() + + // Do any additional setup after loading the view. + } + + override func didReceiveMemoryWarning() { + super.didReceiveMemoryWarning() + // Dispose of any resources that can be recreated. + } + + override func viewWillAppear(animated: Bool) { + super.viewWillAppear(animated) + + if let navigationController = navigationController { + + navigationController.navigationBar.backgroundColor = nil + navigationController.navigationBar.translucent = true + navigationController.navigationBar.shadowImage = nil + navigationController.navigationBar.barStyle = UIBarStyle.Default + navigationController.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default) + + let textAttributes = [ + NSForegroundColorAttributeName: UIColor.yepTintColor(), + NSFontAttributeName: UIFont.navigationBarTitleFont() + ] + + navigationController.navigationBar.titleTextAttributes = textAttributes + navigationController.navigationBar.tintColor = nil + } + } + + /* + // MARK: - Navigation + + // In a storyboard-based application, you will often want to do a little preparation before navigation + override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { + // Get the new view controller using segue.destinationViewController. + // Pass the selected object to the new view controller. + } + */ + +} diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index 692275d7..29771fbb 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -11,7 +11,7 @@ import RealmSwift import AVFoundation import MobileCoreServices -class ConversationViewController: UIViewController { +class ConversationViewController: BaseViewController { struct Notification { static let MessageSent = "MessageSentNotification" diff --git a/Yep/ViewControllers/CustomNavigationBar/CustomNavigationBarViewController.swift b/Yep/ViewControllers/CustomNavigationBar/CustomNavigationBarViewController.swift index 582f8303..362fb806 100644 --- a/Yep/ViewControllers/CustomNavigationBar/CustomNavigationBarViewController.swift +++ b/Yep/ViewControllers/CustomNavigationBar/CustomNavigationBarViewController.swift @@ -32,24 +32,4 @@ class CustomNavigationBarViewController: UIViewController { } } -// override func viewWillDisappear(animated: Bool) { -// super.viewWillDisappear(animated) -// -// if let navigationController = navigationController { -// -// navigationController.navigationBar.backgroundColor = nil -// navigationController.navigationBar.translucent = true -// navigationController.navigationBar.shadowImage = nil -// navigationController.navigationBar.barStyle = UIBarStyle.Default -// navigationController.navigationBar.setBackgroundImage(nil, forBarMetrics: UIBarMetrics.Default) -// -// let textAttributes = [ -// NSForegroundColorAttributeName: UIColor.yepTintColor(), -// NSFontAttributeName: UIFont.navigationBarTitleFont() -// ] -// -// navigationController.navigationBar.titleTextAttributes = textAttributes -// navigationController.navigationBar.tintColor = nil -// } -// } }