slackhq / SlackTextViewController

⛔️**DEPRECATED** ⛔️ A drop-in UIViewController subclass with a growing text input view and other useful messaging features
https://slack.com/
MIT License
8.32k stars 1.08k forks source link

navigationController is nil when changing textInputbar.textView.font #459

Open wpK opened 8 years ago

wpK commented 8 years ago

First of all I want to thank the Slack team for open sourcing and maintaining this project.

I encountered a strange bug when updating from 1.9.1 causing the navigation title bar to disappear. Turns out self.navigationController was nil in viewDidLoad().

I finally narrowed it down to me changing self.textInputbar.textView.font in my init(). I haven't investigated too much into the underlying cause yet, but here is a simple example to reproduce (1.9.2+):

import UIKit
import SlackTextViewController

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
    self.window?.rootViewController = UINavigationController(rootViewController: ViewController())
    self.window?.makeKeyAndVisible()
    return true
  }
}

class ViewController: SLKTextViewController {

  init() {
    super.init(tableViewStyle: .Plain)
    self.textInputbar.textView.font = UIFont.systemFontOfSize(10)
  }

  required init(coder decoder: NSCoder) {
    fatalError("init(coder:) has not been implemented")
  }

  override func viewDidLoad() {
    super.viewDidLoad()
    NSLog("self.navigationController = \(self.navigationController)")
  }

}

This will output the following:

self.navigationController = nil

develth commented 7 years ago

+1

As soon as i apply "super.init(tableViewStyle: .Plain)" the navigation Controller is nil