cellForRowAtIndexPath:
CGRect nameValueRect = CGRectMake(80, 5, 200, 15);
UILabel *nameValue = [[UILabel alloc] initWithFrame:
nameValueRect];
nameValue.tag = kNameValueTag;
[cell.contentView addSubview:nameValue];
[nameValue release];
...
NSUInteger row = [indexPath row];
NSDictionary *rowData = [self.computers objectAtIndex:row];
UILabel *name = (UILabel *)[cell.contentView viewWithTag:
kNameValueTag];
name.text = [rowData objectForKey:@"Name"];
This code is from a tutorial that I'm using which creates a subview within the cell to add some text.
However, what I want to do is instead of adding text I will place an image.
I tried UIImageView *pos开发者_运维技巧terValue = [[UIImageView alloc] initWith... oh there's no initWithFrame for UIImageView.
Perhaps, someone can explain the process for an image. Do I even need to set the frame size for a UIImageView? I would need to position it.
EDIT:
my new code:
UIImageView *posterValue = [[UIImageView alloc] initWithFrame:CGRectMake(0,0,105,175)];
posterValue.tag = kPosterValueTag;
[cell.contentView addSubView:posterValue];
[posterValue release];
addSubView is not working for UIImageView. Says UIView may not respond to addSubView
It's addSubview not addSubView - case matters.
精彩评论