How can I have a UITableView that permits scrolling above a certain index row, but prevents it when it below a certain point? For example, if I have rows 1 through 100, where only 5 appear in the view at a given time, I want to allow a user to scroll among rows 1-50, but prevent any further scrolling down when row 50 is visible.
相关问题
- CALayer - backgroundColor flipped?
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- xcode 4 garbage collection removed?
- Unable to process app at this time due to a genera
- Enum with associated value conforming to CaseItera
You can use the property
contentInset
ofUITableView
just for that. Just remember to set them with minus values, cause we are shrinking the content size:The other solution is to implement
UIScrollViewDelegate
methodscrollViewDidScroll:
and whenscrollView.contentOffset
is too huge, set it back to the max value that user can scroll to:First solution has both the advantage and disadvantage since then
UIScrollView
will manage the bouncing (just like in pull to refresh). It's more natural and HIG-compatible, but if you really need user not to see below the certain row, use delegate method.UITableView is a subclass of UIScrollView. This means you can use all methods from
UIScrollViewDelegate
. Try adding thescrollView.contentOffset
logic in the following delegate method: