In an iPad application I’m developing, I want to show a UITableView that does not scroll and does not bounce (meaning that attempting to scroll the tableview up or down does not show the scroll and snap-back effect). The reason I want to do this is that the UITableView contains a fixed number of cells, and divides the visible space equally among the number of cells (in tableView:heightForRowAtIndexPath:). There won’t be any need to scroll. UITableView and UIScrollView are implementation details of which the user does not need to be aware.
UIScrollView has a boolean bounces property which I could set to NO if I could access the UIScrollView instance.
I expect that the UITableViewController’s UITableView instance has a superview of UIScrollView. However, within my UITableViewController subclass, self.view.superview and self.tableView.superview are both nil. I have determined this within my UITableViewController’s -initWithStyle:, -viewDidLoad, and -viewWillAppear: methods.
Is there another way to access the UIScrollView that contains my UITableView? I’m imagining that this technique would involve the least code, although there is no direct accessor to the UIScrollView instance from UITableViewController or UITableView.
Or should I subclass UIViewController instead of UITableViewController, and instantiate a UITableView that is not enclosed in a UIScrollView? Or is there another option I’ve overlooked?
UITableViewis a subclass ofUIScrollView, soUITableViewhas bounces properties (all properties thatUIScrollViewhas).So to cancel bounces you need to write
self.tableView.bounces = NO;. To cancel scroll,self.tableView.scrollEnabled = NO;And of course you can set this properties using Interface Builder.