about 11 years ago
Hi all, If you want to add two different xibs in a tableView you can check out the code here.
- - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
- {
- if (tableView==carTable)
- {
- ReviewModel *reviewObject=[dictArray objectAtIndex:indexPath.row];
- static NSString *CellIdentifier = @"ReviewCell";
- cell = (ReviewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
- cell = nil;
- BOOL noImage = reviewObject.photo.length == 0;
- if (cell == nil) {
- NSArray *nib = [[NSBundle mainBundle]loadNibNamed:noImage?@"SearchCellWithoutImage":@"ReviewCell" owner:self options:nil];
- cell = [nib objectAtIndex:0];
- }
- if (!noImage) {
- // code for one xib (function calls)
- }else
- {
- // code for other xib(function calls)
- }
- return cell;
- }
- }
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { if (tableView==carTable) { ReviewModel *reviewObject=[dictArray objectAtIndex:indexPath.row]; static NSString *CellIdentifier = @"ReviewCell"; cell = (ReviewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; cell = nil; BOOL noImage = reviewObject.photo.length == 0; if (cell == nil) { NSArray *nib = [[NSBundle mainBundle]loadNibNamed:noImage?@"SearchCellWithoutImage":@"ReviewCell" owner:self options:nil]; cell = [nib objectAtIndex:0]; } if (!noImage) { // code for one xib (function calls) }else { // code for other xib(function calls) } return cell; } }
Can you help out the community by solving one of the following Manual Testing problems?
Do activity (Answer, Blog) > Earn Rep Points > Improve Rank > Get more opportunities to work and get paid!
For more topics, questions and answers, please visit the Tech Q&A page.
0 Comment(s)