Created
September 26, 2011 15:41
-
-
Save anonymous/1242530 to your computer and use it in GitHub Desktop.
cell using nib
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 { | |
static NSString *CellIdentifier = @"Cell"; | |
UITableViewCell *cell = | |
[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; | |
if (cell == nil) { | |
[[NSBundle mainBundle] loadNibNamed:@"MyCell" owner:self options:nil]; | |
cell = self.tvc; | |
} | |
UILabel* lab = (UILabel*)[cell viewWithTag: 2]; | |
// ... set up lab here ... | |
// notice how much less of this there now is, because it's mostly done in the nib | |
lab.text = @"label"; | |
UIImageView* iv = (UIImageView*)[cell viewWithTag: 1]; | |
// ... set up iv here ... | |
UIImage* im = [UIImage imageNamed:@"image.png"]; | |
UIGraphicsBeginImageContextWithOptions(CGSizeMake(35,35), YES, 0.0); | |
[im drawInRect:CGRectMake(0,0,35,35)]; | |
UIImage* im2 = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); | |
iv.image = im2; | |
iv.contentMode = UIViewContentModeCenter; | |
return cell; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment