I can't change the text of a UILabel or the image in an ImageView, in a children subView. (I don't get any exception, but I just see the original content as specified in UIBuilder).
The parent is EventsTableViewController:
The subview ImageWithCaptionView:
and
thanks
The parent is EventsTableViewController:
Code:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
NSArray *photoIds = [[NSArray alloc] initWithObjects:@"2654899252",@"2654072649",@"2654072293",nil];
NSEnumerator *e = [photoIds objectEnumerator];
id object;
CGFloat offset = 0.0;
while ((object = [e nextObject])) {
ImageWithCaptionView* imageWithCaptionView = [[[ImageWithCaptionView alloc] init] retain];
offset += 320.0;
UIGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTap:)];
[(UITapGestureRecognizer *)recognizer setNumberOfTouchesRequired:1];
imageWithCaptionView.userInteractionEnabled = YES;
[imageWithCaptionView addGestureRecognizer:recognizer];
recognizer.delegate = self;
[recognizer release];
dispatch_queue_t downloadQueue = dispatch_queue_create("Flickr downloader in EventsTableView", NULL);
dispatch_async(downloadQueue, ^{
NSData *image = [FlickrFetcher imageDataFromPhotoId:object];
if(image) {
//imageWithCaptionView.imageView.image = [UIImage imageWithData: image];
imageWithCaptionView.imageView = [[UIImageView alloc] initWithImage:[UIImage imageWithData: image]];
}
});
dispatch_release(downloadQueue);
[imageWithCaptionView.label setText:@"testBALBALBAL"];
[cell addSubview:imageWithCaptionView];
[imageWithCaptionView release];
}
[photoIds release];
return cell;
}
The subview ImageWithCaptionView:
Code:
@interface ImageWithCaptionView : UIView {
IBOutlet UIImageView *imageView;
IBOutlet UILabel *label;
}
@property (retain) IBOutlet UIImageView *imageView;
@property (retain) IBOutlet UILabel *label;
and
Code:
@implementation ImageWithCaptionView
@synthesize imageView, label;
-(id)init
{
UINib *nib = [[UINib nibWithNibName:NSStringFromClass([ImageWithCaptionView class]) bundle:nil] retain];
NSArray *myArray = [nib instantiateWithOwner:self options:nil];
for (id currentObject in myArray) {
if ([currentObject isKindOfClass:[ImageWithCaptionView class]]) {
self = (ImageWithCaptionView *) currentObject;
break;
}
}
[nib release];
return self;
}
thanks
Last edited by a moderator: