views:

229

answers:

1

Hi I am having issues loading the image from an xml file. I was wondering if someone might be able to help

   //
//  BookDetailViewController.m
//  XML
//
//  Created by iPhone SDK Articles on 11/23/08.
//  Copyright 2008 www.iPhoneSDKArticles.com.
//

#import "BookDetailViewController.h"
#import "Book.h"

@implementation BookDetailViewController

@synthesize aBook;

/*
// Override initWithNibName:bundle: to load the view using a nib file then perform additional customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically.
- (void)loadView {
}
*/


// Implement viewDidLoad to do additional setup after loading the view.
- (void)viewDidLoad {
    [super viewDidLoad];

    self.title = @"Book Detail";
}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];

    [tableView reloadData];
}


- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
    }

    switch(indexPath.section)
    {
        case 0:
            cell.text = aBook.title;
            break;
        case 1:
            cell.text = aBook.author;
            break;
        case 2:
            cell.text = aBook.summary;
            break;
        case 3:
            UIImage *img = [[UIImage alloc] initWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://www.google.com.au/logos/olympics10-icedance-hp.png"]]];

            break;

    }

    return cell;
}

- (NSString *)tableView:(UITableView *)tblView titleForHeaderInSection:(NSInteger)section {

    NSString *sectionName = nil;

    switch(section)
    {
        case 0:
            sectionName = [NSString stringWithString:@"Title"];
            break;
        case 1:
            sectionName = [NSString stringWithString:@"Author"];
            break;
        case 2:
            sectionName = [NSString stringWithString:@"Book Summary"];
            break;
    }

    return sectionName;
}

- (void)dealloc {

    [aBook release];
    [tableView release];
    [super dealloc];
}


@end
A: 

If you want to show the image in your table view then you have to implement a UIImageView in your table view for showing the image.

raaz