
Untitled
By: a guest on
Jul 30th, 2012 | syntax:
None | size: 1.68 KB | hits: 25 | expires: Never
Placeholder cell in a UITableView
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
{
if(section == 1)
{
return @"Section One";
}
if(section == 0)
{
return @"Section Two";
}
return @"";
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (section == 1)
{
return self.sectionOne.count;
}
else
{
return self.sectionTwo.count;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSArray *theSource =[[NSArray alloc] init];
if(indexPath.section == 1)
{
theSource = self.sectionOne;
}
else
{
theSource = self.sectionTwo;
}
// See if there's an existing cell we can reuse
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
if (cell == nil)
{
// No cell to reuse => create a new one
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellIdentifier"];
cell.backgroundView = [[UIImageView alloc] init];
// Continue creating cell
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
if (datasource == empty)
return 1;
else
return [datasource count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (datasource == empty)
return stub cell;
else
return regular cell;
}
sectionTitleArray = [@"First Section", @"Second Section", @"Third Section"]