Noodledew
Noodledew

Reputation: 519

UITableView rows are buggy when navigating to another ViewController

I have a TableView in my application which displays some events. When I click on it, it navigates to the event clicked. My struggle is, that the whole navigation process / animation looks very ugly. The rows disappear when the new ViewController is already present.

I managed to screenshot it, so you could understand better how it looks. Tableview Navigation

Code looks like this:

func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
    tableView.deselectRow(at: indexPath, animated: false)
    guard let parent = parentVC else { return }
    guard let id = twoDimensionalEventArray[indexPath.section].events[indexPath.row].eventID else { return }
    parent.gotoEvent(eventID: id)
}

func gotoEvent(eventID: Int) {
    let event = eventArray[eventID]
    let eventVC = SingleEventViewController(event: event)
    self.navigationController?.pushViewController(eventVC, animated: true)
}

Does someone know how to solve this issue?

Because two people suggested I provide my Viedloading of the SingleEventVuewController, here it is:

init(event: Event) {
    thisEvent = event
    super.init(nibName: nil, bundle: nil)
    setupDefaultValues()
    self.view.backgroundColor = .white
}

override func viewDidLoad() {
    super.viewDidLoad()
    applyDefaultValues()
    setupNavBar()
    setupViews()
    confBounds()
    getSnapshotForLocation()
}

Upvotes: 0

Views: 63

Answers (2)

Shemona Puri
Shemona Puri

Reputation: 811

Set background color content view of cell as white in storyboard . Please refer the screenshot enter image description here

Upvotes: 0

Soham Ray
Soham Ray

Reputation: 215

Set the backgroundColor to white like self.view.backgroundColor = .white in viewDidLoad() of the detail view controller or you could set it in storyboard if you done it that way.

Upvotes: 1

Related Questions