1

My app has a set of categories. A category can have sub-categories.

DirectoryCategoryController is the first screen, displaying all the top-level categories. Works great. When you tap a cell, if the category selected has sub-categories, I instantiate a new instance of DirectoryCategoryController and push it to display the sub-categories. From there, you tap a sub-category and see the contents.

The problem is that while the top level works fine, when I tap in and see the sub-categories, the table view won't scroll. The search bar takes touches, the table cells take touches but up and down scrolling does not work, like the table view is vertically frozen in space.

If I tap the search bar and hit cancel or if I go into a sub-categories contents and then hit back, the very same table view that didn't scroll works just fine.

Also, if the table view has more items than fit on the screen (about anything bigger than 8 in this layout), everything works.

Very odd problem ; kinda blowing my mind. Any insight?

Hunter
  • 4,343
  • 5
  • 42
  • 44
  • 1
    "if the table view has more items than fit on the screen..., everything works" If you have fewer items, then table doesn't need to scroll, no? – mahboudz Oct 06 '09 at 03:54
  • 1
    The problem is things 'almost' fit. It appears to be a bug in iPhone OS where it just misses determining if scrolling is required. – Hunter Oct 07 '09 at 23:23

2 Answers2

15

So, I figured this out and thought I would answer as a reference.

At this point, I think it may be an iPhone OS bug and I'm filing a RADAR.

A UIScrollView, of which UITableView is a subclass, will not attempt to scroll if everything fits on one screen.

In my case, it appears the scroll view thought everything fit (it was very close) but it didn't. Actually, if you removed the UISearchBar from the UITableView, everything would have fit and it wouldn't need to scroll. My guess is that it's incorrectly determining the geometry when the UISearchBar is attached.

Anyway, the work-around was to add this: [self.tableView setAlwaysBounceVertical:YES];

The odd thing was that when another view was pushed and then popped, the vertical bounce worked fine, furthering my suspicions it's an iPhone bug.

Hunter
  • 4,343
  • 5
  • 42
  • 44
  • Thanks @Hunter! I just had exactly the same problem with iOS 4.3.3 and Xcode 4.0.2. And you solution still works!!! Thanks!!! – Di Wu Jun 18 '11 at 16:38
  • Also just helped me stop banging my head against the table, thanks. – GregularExpressions Mar 06 '12 at 17:03
  • I wish I could upvote this multiple times. I have run into this on multiple apps. I just did some testing in the simulator - it still occurred on iOS 5.0 and 5.1, but seems fixed in 6.0. – Jeremy Sep 21 '12 at 02:35
0

I noticed the same thing when using A UITableView with a UISearchBar as the header view, as configured in Interface Builder in Xcode 4.3.1. In my viewDidLoadMethod, I added the following code and it fixed the problem for me:

self.contactsTable.bounces = YES;

I believe that it's a bug that disables the bounces property, but it can be fixed by re-enabling it.

Moshe
  • 57,511
  • 78
  • 272
  • 425