rottendevice
rottendevice

Reputation: 2879

Preventing UITableView from scrolling?

This seems like it'd be a common question, so apologies if it's been asked before.

I'm trying to figure out how to prevent UITableView from scrolling in my iPhone application altogether. I want my table to be vertically locked, so that no amount of screen swiping will cause it to move.

How do I implement this? Thanks.

Upvotes: 10

Views: 9654

Answers (2)

Jhaliya - Praveen Sharma
Jhaliya - Praveen Sharma

Reputation: 31722

UITableView is inherited from UIScrollView so Use scrollEnabled property of UIScrollView

self.tableView.scrollEnabled = NO

http://developer.apple.com/library/ios/#documentation/uikit/reference/UIScrollView_Class/Reference/UIScrollView.html#//apple_ref/occ/cl/UIScrollView

Upvotes: 5

Parth Bhatt
Parth Bhatt

Reputation: 19469

You can do that from your XIB as well as programmatically.

From XIB:

Just select the tableView and in Inspector uncheck bounce horizontally & bounce vertically and scroll horizontally and scroll vertically

Programmatically:

If you want to do that programmatically then you can try

self.tableView.scrollEnabled = NO; 

OR

[self.tableView setScrollEnabled:NO];

Hope this helps you.

Upvotes: 36

Related Questions