2010-02-22 3 views
0

안녕하세요, 저는 XML 파일에서 이미지를로드하는 데 문제가 있습니다. 그런 다음 이미지를 보여주는 테이블보기에서있는 UIImageView를 구현해야 테이블보기에서 이미지를 표시하려면 누군가가XML에서 UIImage의 이미지로드

// 
// 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 
+0

그리고이 코드의 문제점은 정확히 무엇입니까? – Vladimir

+0

또한'dataWithContentsOfURL'을 사용하지 마십시오. 이유는 다음과 같습니다. http://developer.apple.com/library/ios/#qa/qa2010/qa1693.html –

답변

0

을 도울 수있을 수 있는지 궁금 해서요.