Im using a UITableview to display data from a NSDictionary from TouchXML. TouchXML is a system to integrate XML feeds within my iPhone application.
For the Tableview this all works, i put the NSdictionary like this in my UITableview:
[[[newsEntries objectAtIndex:indexPath.row] objectForKey: @"still"] retain];
Now i am using the iCarousel software, its an opensource CoverFlow like system. Before i have used the AFOpenFlowView but this is just a pain becouse it won't accept UIViews. Only images.
I need to load thumbnails in the iCarousel from the XML. So i need to get a string from the dictionary and change it to a UIImage.
I made this work. The problem i'm having is that i need to load multiple images in the iCarousel just like you would load multiple images/thumbnails in your TableView row. Now i开发者_如何学C need to do the same with the iCarousel, but how?
This is how fare i currently am. Problem is a TableView has a indexPath.row and this viewForItemAtIndex doesn't.
- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index {
//create a numbered view
NSString *imageUrl = [[[newsEntries objectAtIndex:indexPath.row] objectForKey:@"still"] retain];
NSData* imageData = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:imageUrl]];
UIView *view = [[[UIImageView alloc] initWithData:imageData] autorelease];
UILabel *label = [[[UILabel alloc] initWithFrame:view.bounds] autorelease];
label.text = [NSString stringWithFormat:@"%i", [[items objectAtIndex:index] intValue]];
label.backgroundColor = [UIColor clearColor];
label.textAlignment = UITextAlignmentCenter;
label.font = [label.font fontWithSize:50];
[view addSubview:label];
return view;
}
Shouldn't replacing indexPath.row
with index
work?
NSString *imageUrl = [[[newsEntries objectAtIndex:index] objectForKey:@"still"] retain];
- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
return [items count];
}
This is response when i log the string with the object for key
2011-06-01 14:57:51.273 [711:207] my url = (null)
2011-06-01 14:57:51.277 [711:207] my url = (null)
etc. etc. etc.
精彩评论