iOS TableView Cell for 3 different articles

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
I want to create a custom cell for a TableView that will contain 3 UIImageViews, loading a different picture in each from separate entries in an XML file. I know that I can create a custom cell for the TableView, but am not sure where to go from there. How to set the number of rows based off number of entries in the XML, and how to set each of the 3 UIImageViews in the custom cell to load a different Image, and have those each behave differently when selected, instead of one action for the entire row.

Thanks
 

jnoxx

macrumors 65816
Dec 29, 2010
1,343
0
Aartselaar // Antwerp // Belgium
depends how your XML Data is structures, you have several ways.. You can create objects from your XML Structure, and give the properties to the above said "Custom Cell", or you just have 1 big array, you clip a piece of array out of it, for each "row", and just set those 3 elements from the array as properties onto your "Custom Cell" :/
It's not "that" easy if you are kinda new ^_-
 
Comment

newtoiphonesdk

macrumors 6502a
Original poster
Jul 30, 2010
567
2
depends how your XML Data is structures, you have several ways.. You can create objects from your XML Structure, and give the properties to the above said "Custom Cell", or you just have 1 big array, you clip a piece of array out of it, for each "row", and just set those 3 elements from the array as properties onto your "Custom Cell" :/
It's not "that" easy if you are kinda new ^_-
Code:
-(void)viewDidLoad {
 self.allEntries = [NSMutableArray array];
    self.queue = [[[NSOperationQueue alloc] init] autorelease];
    self.feeds = [NSArray arrayWithObjects:@"http://address.com/photos.xml", 
                  nil];  
    [self refresh];    

}
- (void)refresh {
    
    for (NSString *feed in _feeds) {
        NSURL *url = [NSURL URLWithString:feed];
        ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
        [request setDelegate:self];
        [_queue addOperation:request];
    }
    
}
Then when I parse I set this up:
Code:
- (void)parseRss:(GDataXMLElement *)rootElement entries:(NSMutableArray *)entries {
    
    NSArray *channels = [rootElement elementsForName:@"channel"];
    for (GDataXMLElement *channel in channels) {            
        
        NSString *blogTitle = [channel valueForChild:@"title"];                    
        
        NSArray *items = [channel elementsForName:@"item"];
        for (GDataXMLElement *item in items) {
            NSString *articleTitle = [item valueForChild:@"title"];
            NSString *articleUrl = [item valueForChild:@"guid"];            
            NSString *articleDateString = [item valueForChild:@"pubDate"];   
            NSString *articleImage = [item valueForChild:@"image"];
            NSDate *articleDate = [NSDate dateFromInternetDateTimeString:articleDateString formatHint:DateFormatHintRFC822];
            RSSEntrySermons *entry = [[[RSSEntrySermons alloc] initWithBlogTitle:blogTitle articleTitle:articleTitle articleUrl:articleUrl articleDate:articleDate articleImage:articleImage] autorelease];
            
            
            [entries addObject:entry];
        }      
    }
    
}
I use a tutorial and GDATAXML library to parse it and currently on my cellForRowAtIndexPath, I have:
Code:
    RSSEntry *entry = [_allEntries objectAtIndex:indexPath.row];
NSString *pictureURLwithstring = entry.articleImage;
Where RSSEntry is a class that was used in the tutorial for parsing the different elements.

Would I be able to simply parse it in a Custom Cell created? Not sure how to get it in 3 images per cell, so that from left to right it would be:
entry.articleImage(first picture) entry.articleImage(from 2nd pic) entry.aritcleImage(from 3rd pic)
 
Comment

Similar threads

  • theprizerevealed
4
Replies
4
Views
1K
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.