Sunday, April 21, 2019

Bouncing Issue: Tap on Static TableView Content

Recently I found a really wired problem in my app. It took me several weeks to resolve the issue. I would like to write this blog to record this issue.

Here is the simplified case. I have a view controller based on UITableViewController. The table view is a static table view with several cells predefined in storyboard. Each cell has various height. The following is an example:



In cell Row2, there is a text view controller for editing a note.

When I run my app, I tap on edit button to change the text view into edit mode. This would cause the table view bouncing/jumping back and forth. At the end of this movement, the screen will stay at cell row 2 to allow me to edit the node. I don't like this kind of jumping movement.



When I test my app, I realize that I have another similar table view for editing note. That one does not have this jumping issue. Ok, I thought there must be something different to cause the issue.

I tried to compare every thing between those two screens, in storyboard settings and in view controller codes. I could not find anything obvious thing to cause the issue.

Finally, by carefully analyzing codes in both view controllers, I found that there is one line of code that caused the issue!

In smooth-none-jumper view controller, in the override func of viewDidAppear(), there is no call to its super class; while in the jumping one, the super class method of viewDIdAppear() is called, as in normal practice.

  1. override func viewWillAppear(_ animated: Bool) {
  2.  // Call base class method will cause edit note jumpping
  3.  // super.viewWillAppear(animated)
  4.  ...
  5. }

This is the first time I encounter the case that the base class method should not be called, as in my comment above.

With this solution and change, my screen becomes smooth when I tap on the edit button:



By the way, I like to use static table view for my editing screens because the table view is a scrollable view.

Read More...