UITableView, setContentOffset animated:NO will not scroll on iPad
I have a simple UITableView
; I'm trying to force it to scroll to a certain position in viewDidLoad
, so I can hide the first row in my table (unless a user scrolls up). My first row is 90.0px
in height, so I'm trying this to force my UITableView
to scroll:
[contentTable setContentOffset: CGPointMake(0, 90.0f) animated: NO开发者_Go百科];
The problem is that using animated: NO
does nothing; the UITableView
will not scroll. If I use animated: YES
, however, things work just fine; it scrolls, but the downside to having it animated is that my UI appears to flash during the scroll, which is not what I want at all.
Any ideas why? It doesn't seem to matter if my UITableView
has 1 row or 20 rows, it will only scroll if I pass animated: YES
to setContentOffset
.
I am currently running Xcode 4.2 and I'm using iOS 4.3.3 on my first-gen iPad.
Edit: One other thing to mention - scrollToRect
doesn't seem to work at all, regardless of what value I pass for it's animated
property. Is there something I'm fundamentally misunderstanding about scrolling on iOS?
Potential duplicates:
setContentOffset only works if animated is set to YES
UITableView won't scroll to certain position
I'm pretty sure there's something buggy about UITableView scrolling. I'm using:
selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionMiddle
It's supposed to select the row indicated by indexPath and then scroll the table so the selected row is in the middle of the view. It reliably works that way on the simulator but on the iPhone it sometimes scrolls and sometimes doesn't. Often (but not always) it works the first few times and then stops working (i.e., it doesn't scroll and the selected cell is off screen). But the correct cell is always selected. I haven't been able to pin down what governs whether it scrolls or not. I submitted a bug report to Apple but no response.
精彩评论