Reputation: 13549
I'm trying to put a signifier between two different types of data being fed into my dynamic UITableView. Am I allowed to split the data into two sections or would I have to just feed in a non-userInteractionEnabled cell to mark the split? I cannot programmatically set the numberOfSections property. Does anyone know how to get around this?
Upvotes: 1
Views: 1815
Reputation: 4914
What you are trying to do is creating a grouped table view , make sure in your interface builder you chose grouped tableview option for your table view
then call grouped table view methods such as
// for sections I guess you want 2 sections
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 2;
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section {
if(section==0)
return [yourdatasource count]; // make sure that each section is returned here
if(section==1)
return [anotherdatasource count];
}
// set header height of gropued tableview
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section {
return 60.0; // choose your height for each section
}
//set header section labels
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
}
my code is not tested,
Look at this http://www.mobisoftinfotech.com/blog/iphone/iphone-uitableview-tutorial-grouped-table/ for further info
Upvotes: 1