How to restrict the tables in UITableView? i have only 5 cell data. I need to restrict the count of rows to 5...
A:
If you have one section, use the numberOfRowsInSection: protocol method as described here: http://developer.apple.com/library/ios/#documentation/uikit/reference/UITableViewDataSource_Protocol/Reference/Reference.html%23//apple_ref/occ/intf/UITableViewDataSource
Evan Mulawski
2010-10-26 14:19:51
+1
A:
Use the methods defined in the UITableViewDataSource protocol. In your table view controller, implement
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
to define how many sections your table is going to have (in this case probably one) and
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return 5;
}
to limit the rows in every section to five. Of course, you can divide your five cells into multiple sections. Just return in the first methods, how many sections you are going to have and use an if
statement to return the according number of rows in the second method.
muffix
2010-10-26 14:39:30
Thanks a lot....
Chinthan Kyasanur
2010-10-29 13:43:09