Created
May 19, 2012 15:57
-
-
Save ninthspace/2731310 to your computer and use it in GitHub Desktop.
Setting the content of a UITableViewCell
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
- (void)setWithTaskItem:(TaskItem *)task { | |
// set the text which displays the title of the task | |
NSString *text = [task title]; | |
UILabel *titleLabel = [self taskTitleLabel]; | |
[titleLabel setText:text]; | |
// create a checkbox appropriately set according whether the task is completed or not | |
NSString *completedString = @""; | |
if ([task complete]) { | |
completedString = @"completed-"; | |
[titleLabel setTextColor:[UIColor lightGrayColor]]; | |
} else { | |
[titleLabel setTextColor:[UIColor blackColor]]; | |
} | |
NSString *imageName = [[NSString alloc] initWithFormat:@"%@checkbox.png", completedString, nil]; | |
NSString *imageHighlightedName = [[NSString alloc] initWithFormat:@"highlighted-%@checkbox.png", completedString, nil]; | |
UIImageView *checkbox = [self checkboxImage]; | |
[checkbox setImage:[UIImage imageNamed:imageName]]; | |
[checkbox setHighlightedImage:[UIImage imageNamed:imageHighlightedName]]; | |
// set the text which describes the task ID | |
[taskIDLabel setText:[[task uniqueID] stringValue]]; | |
// add a recognizer for long press operations | |
[self addLongPressRecognizer]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment