how can load images from plist in to UITableView ?

Posted by srikanth rongali on Stack Overflow See other posts from Stack Overflow or by srikanth rongali
Published on 2010-04-23T06:46:49Z Indexed on 2010/04/23 6:53 UTC
Read the original article Hit count: 421

I have stored the videos and the thumbnail images of the videos in Documents folder. And I have given the path in plist. In plist I took an array and I added directories to the array. And in the dictionary I stored the image path

/Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/image1  

for key imagePath.

for video

/Users/srikanth/Library/Application Support/iPhone Simulator/User/Applications/9E6E8B22-C946-4442-9209-75BB0E924434/Documents/video1.mp4

for key filePath.

I used following code but it is not working. I am trying only for images. I need the images to be loaded in the table in each cell.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) 
    {
       cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];

        [cell setAccessoryType:UITableViewCellAccessoryDetailDisclosureButton];
        UIImageView *image2 = [[UIImageView alloc]init];
        image2.frame = CGRectMake(0.0f, 0.0f, 80.0f, 80.0f);
        image2.backgroundColor = [UIColor clearColor]; 
        //image2.image = [UIImage imageNamed:@"snook.png"];
        image2.tag = tag7;
    }
    NSDictionary *dictOfplist = [cells objectAtIndex:indexPath.row];
    [(UIImageView *)[cell viewWithTag:tag7] setImage:[dictOfplist objectForKey:@"imagePath"]];
    return cell;
}  

- (void)viewDidLoad 
{
    [super viewDidLoad];
    self.title = @"Library";
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(close:)];

    NSString* plistPath = [[NSBundle mainBundle] pathForResource:@"details" ofType:@"plist"];
    contentArray = [NSArray arrayWithContentsOfFile:plistPath];

    cells = [[NSMutableArray alloc]initWithCapacity:[contentArray count]];

    for(dCount = 0; dCount < [contentArray count]; dCount++)
        [cells addObject:[contentArray objectAtIndex:dCount]];
}

How can I make this work. Thank you.

© Stack Overflow or respective owner

Related posts about cocoa-touch

Related posts about iphone-sdk-3.0