How to display 3 UableviewCells with 3 different cell identifiers in single controller in lens c

advertisements

I have a singleview controller , in that 3 buttons are there, Let us assume A,B,C tabs and when i click on Tab "A", i need to display the uitableview cell corresponding to that Cellidentifier I know how to implement for 2 Uitableviewcell , but i had more than two please help ,

 -(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        NSString *CellIdentifier = @"";
        if (!A) {
            //Get the top cell
            CellIdentifier = @"Cell-IdentifierA";
        }
         else if (B)
        {
            //Get bottom cell
            CellIdentifier = @"Cell-IdentifierB";
        }


Create a global variable

NSString *selectedCell = @"FirstCellIdentifier"

On click of each button

selectedCell = @"newCellIdentifier" //and reload tableview

And finally in

- (UITableViewCell *)tableView:(UITableView *)tableView
     cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if ([selectedCell isEqualToString:@"FirstCellIdentifier"]) {
         return firstCell
    } else if ([selectedCell isEqualToString:@"SecondCellIdentifier"]) {
         return secondCell
    } else if ([selectedCell isEqualToString:@"ThirdCellIdentifier"]) {
         return thirdCell
    }
}