tags:

views:

23

answers:

2

How to restrict the tables in UITableView? i have only 5 cell data. I need to restrict the count of rows to 5...

+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
Thanks a lot....
Chinthan Kyasanur