Created
February 23, 2013 07:02
-
-
Save romyilano/5018770 to your computer and use it in GitHub Desktop.
creating alternating cell types
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -(UITableViewCell *)tableView:(UITableView *)tableView | |
| cellForRowAtIndexPath:(NSIndexPath *)indexPath | |
| { | |
| NSString *CellIdentifier; | |
| // nice! make the conditional here | |
| if ((indexPath.row %2) == 0 ) { | |
| CellIdentifier = @"rowOdd"; | |
| } else { | |
| CellIdentifier = @"rowEven"; | |
| } | |
| } | |
| UITableViewCell *cell = [tableView | |
| dequeueReusableCellWithIdentifier:CellIdentifier]; | |
| if (cell == nil) { | |
| switch ([CellIdentifier isEqualToString:@"rowOdd"]) { | |
| case YES: | |
| cell = [[UITableViewCell alloc] | |
| initWithStyle:UITableVIewCellStyleDefault | |
| reuseIdentifier:cellIdentifier]; | |
| break; | |
| case NO: | |
| cell = [[UITableViewCell alloc] | |
| initWithStyle:UITableViewCellStyleValue2 | |
| reuseIdentifier:cellIdentifer]; | |
| break; | |
| default: | |
| break: | |
| } | |
| } | |
| cell.textLabel.text = @"textLabel"; | |
| cell.detailTextLabel.text =@"detailTextLabel"; | |
| } | |
| } | |
| return cell; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment