I have two UIButtons
that act like a segmented control
. I also have two custom UITableView cells
, and I the user to be able to toggle between the two types of cells with the buttons. Does anyone know how I can do this? Here is some code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *videoCellID = @"videoCellID";
static NSString *commentCellID = @"commentCellID";
static NSString *relatedCellID = @"relatedCellID";
VideoDetailCell *videoCell;
if (indexPath.row == 0)
{
videoCell = (VideoDetailCell *)[tableView dequeueReusableCellWithIdentifier:videoCellID];
if (!videoCell)
{
videoCell = [VideoDetailCell generateCellWithInfo:nil];
videoCell.navigation = self.navigationController;
}
return videoCell;
}
else
{
if (videoCell.buttonSelected == 0)
{
self.cellType = 0;
CommentCell *commentCell = (CommentCell *)[tableView dequeueReusableCellWithIdentifier:commentCellID];
if (!commentCell)
{
commentCell = [CommentCell generateCellWithInfo:nil];
}
return commentCell;
}
else
{
self.cellType = 1;
RelatedCell *related = (RelatedCell *)[tableView dequeueReusableCellWithIdentifier:relatedCellID];
if (!related)
{
related = [RelatedCell generateCellWithInfo:nil];
}
return related;
}
}
}
The videoCell
is another custom UITableViewCell
, but that will always be the first cell in the UITableView. There is a UIButton to show the commentCell
, and one to show the relatedCell
.