Created
June 29, 2010 08:29
-
-
Save mafis/456968 to your computer and use it in GitHub Desktop.
This file contains 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
//Methode zum berechnen der absoluten Position | |
- (NSInteger)realRowNumberForIndexPath:(NSIndexPath *)indexPath inTableView:(UITableView *)tableView | |
{ | |
NSInteger retInt = 0; | |
if (!indexPath.section) | |
{ | |
return indexPath.row; | |
} | |
for (int i=0; i<indexPath.section;i++) | |
{ | |
retInt += [tableView numberOfRowsInSection:i]; | |
} | |
return retInt + indexPath.row; | |
} | |
//Anwendungsbeispiel | |
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath | |
{ | |
//Absolute Position der aktuellen UITableViewCell zurückbekommen | |
NSInteger realRow = [self realRowNumberForIndexPath:indexPath inTableView:tableView]; | |
//Wenn die absolute Position durch 2 Teilbar ist, wird der Hintergrund lightGrayColor, ansonsten wird sie DunkelGrau | |
cell.backgroundColor = (realRow%2)?[UIColor lightGrayColor]:[UIColor grayColor]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment