2013-03-06 5 views
0

저는 아이폰 개발에 멍청한 사람이고 SDWebImage 라이브러리를 프로젝트에 구현하려고합니다. 그러나 내 tableview 표시 할 때 내 응용 프로그램이 잘못된 인수 예외가 충돌합니다. 나는 철저히 설치 지침을 따랐다. ImageIO 프레임 워크를 추가하고 프로젝트가 ARC가 아니므로 -fobjc-arc 플래그를 추가하고 적절한 헤더를 가져 왔습니다. 어떤 도움이라도 대단히 감사합니다. 당신이 사용하는 경우 (UITableView를 사용하는 SDWebImage에서 예외가 발생하는 이유는 무엇입니까?

#import <SDWebImage/UIImageView+WebCache.h> 

:

MY 예외

'NSInvalidArgumentException', reason: '-[UIImageView setImageWithURL:placeholderImage:]: unrecognized selector sent to instance 0x6e47d50' 

내 코드 해당 파일의 상단 내부

// Customize the appearance of table view cells. 
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

static NSString *CellIdentifier = @"Cell"; 

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

//Lazy Loader 
[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] 
       placeholderImage:[UIImage imageNamed:@"mylogo.png"]]; 

// Configure the cell... 

NSDictionary *aTweet = [tweets objectAtIndex:[indexPath row]]; 

cell.textLabel.text = [aTweet objectForKey:@"text"]; 
cell.textLabel.adjustsFontSizeToFitWidth = YES; 
cell.textLabel.font = [UIFont systemFontOfSize:12]; 
cell.textLabel.minimumFontSize = 10; 
cell.textLabel.numberOfLines = 4; 
cell.textLabel.lineBreakMode = UILineBreakModeWordWrap; 

cell.detailTextLabel.text = [aTweet objectForKey:@"from_user"]; 

NSURL *url = [NSURL URLWithString:[aTweet objectForKey:@"profile_image_url"]]; 
NSData *data = [NSData dataWithContentsOfURL:url]; 
cell.imageView.image = [UIImage imageWithData:data]; 
cell.selectionStyle = UITableViewCellSelectionStyleNone; 
return cell; 
} 
+0

앞으로 ARC를 사용하는 것이 좋습니다. 더 쉽게 작업 할 수 있습니다. 훨씬 쉽습니다. – dotbill

+0

나는 여기에 대답했다 : http://stackoverflow.com/questions/18400602/sdwebimage-sending-unknown-exception –

답변

2

, 당신은 SDWebImage 헤더, 즉를 포함해야 cocoapods .. 그렇지 않으면 something like :)

#import "SDWebImage/UIImageView+WebCache.h" 

또는

#import "UIImageView+WebCache.h" 

편집 :

당신에게 상단에이 코드를 가지고 이유 :

[cell.imageView setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"] 
       placeholderImage:[UIImage imageNamed:@"mylogo.png"]]; 

이 바닥에 다시 설정 한 :

NSURL *url = [NSURL URLWithString:[aTweet objectForKey:@"profile_image_url"]]; 
NSData *data = [NSData dataWithContentsOfURL:url]; 
cell.imageView.image = [UIImage imageWithData:data]; 

yo 두 가지 모두 필요하지 않습니다 - 아마도 그 게으른 로더를 사용하지 않는 하단에있는 코드를 제거할까요?

+0

내 구현에 이미 #import 이있다. –

+0

대답에 대한 내 편집을 참조하십시오. – dotbill

+0

빌드 설정에서 다른 링커 플래그에 -ObjC를 추가하면 uikit이 포함 된 정적 라이브러리가있는 것처럼 외부 라이브러리 플래그 인 http://developer.apple.com으로 바이 패싱해야합니다 /library/mac/#qa/qa1490/_index.html –

관련 문제