IQKeyBoardManager Swift bug with table view

Hello im new at ios, faced a problem and it has been 3 hours and not yet solved I saw that post and answer from 2 years ago (first image) , and my problem seems similar to it but i dont have large titles enabled. so what happens with me is: in image 2: thats without showing keyboard an without scrolling (notice the top(nav bar) and button are yellow colored cause the background color of the whole view is yellow) in image 3 when keyboard showed up, pushing things upward, now the color of the top (nav bar) is gray AS THE TABLE VIEW, but thats not the issue, the issue is that the cells cover the top nav bar !! in image 4, if i drag my mouse up (scroll down), notice the top nav bar color is now purple (cause the bar tint color of the nav bar is set to purple)

i dont really care about change in colors, i can make them all the same color so the change of colors doesnt appear, but my problem is what happens in the 3rd image, when keyboard shows up and the table cells overlap the top nav bar!

thanks in advance

i will also attach more photos showing the navigation bar attributes and that view controller (named Chat view controller here)

Edit 1: The top of the view that contains the table view, is constrained to touch the safe area, so its touching the bottom of the nav bar.

Edit 2: i pushed it on github: https://github.com/MarwanBB/App3x-9.1-FlashChat

Add a Comment

Replies

did you get any luck I''m facing the same problem and I'm just finished flash chat project with Angela ??

Solution

I have been doing Angela's course and have faced the same problem. He is my solution.

Setup navigation bar

Firstly, I configured my navigation bar; I checked the standard and scroll edges under appearances.

ChatViewController

I created a setup function to set my navigation bar and apply the desired background colour.

 func setupNavbar(){
        title = K.appName
        navigationItem.hidesBackButton = true
        let appearance = UINavigationBarAppearance()
        appearance.configureWithOpaqueBackground()
        navigationController?.navigationBar.standardAppearance = appearance
        navigationController?.navigationBar.scrollEdgeAppearance?.backgroundColor = UIColor(named: K.BrandColors.purple)
}

You can then call this function from your viewDidLoad. Like this:

  override func viewDidLoad() {
        super.viewDidLoad()
        setupNavbar()
        tableView.dataSource = self
        tableView.delegate = self
        tableView.register(UINib(nibName: K.cellNibName, bundle: nil), forCellReuseIdentifier: K.cellIdentifier)
        loadMessage()
    }

Welcome Screen

The above code will change the setup for your navigation bar for the entire application. To fix this, I implemented the viewWillApear of the WelcomeViewController so that the nav bar would be fixed every time the welcome screen was added to the view hierarchy.

    override func viewWillAppear(_ animated: Bool) {
        let appearance = UINavigationBarAppearance()
        appearance.configureWithTransparentBackground()
        navigationController?.navigationBar.standardAppearance = appearance
        navigationController?.navigationBar.scrollEdgeAppearance = appearance
    }

Since the other two screens can only be reached by navigating to the welcome screen first, you don't need to change any other code.

Demo

Here is a screenshot of what my UI looks like.