Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Two different custom cells

    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 233
    Comment on it

    Hi all, If you want to add two different xibs in a tableView you can check out the code here.

    1. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    2. {
    3. if (tableView==carTable)
    4. {
    5. ReviewModel *reviewObject=[dictArray objectAtIndex:indexPath.row];
    6.  
    7.  
    8. static NSString *CellIdentifier = @"ReviewCell";
    9. cell = (ReviewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    10. cell = nil;
    11. BOOL noImage = reviewObject.photo.length == 0;
    12.  
    13. if (cell == nil) {
    14. NSArray *nib = [[NSBundle mainBundle]loadNibNamed:noImage?@"SearchCellWithoutImage":@"ReviewCell" owner:self options:nil];
    15. cell = [nib objectAtIndex:0];
    16. }
    17.  
    18. if (!noImage) {
    19. // code for one xib (function calls)
    20. }else
    21. {
    22. // code for other xib(function calls)
    23.  
    24.  
    25.  
    26. }
    27. return cell;
    28. }
    29.  
    30. }

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: