2011-03-10 10 views
1

"예외가 발생하여 응용 프로그램을 종료하는 중 'NSInvalidArgumentException'이유 : '- [UIImage initWithImage :] : 인식 할 수없는 선택기가 인스턴스 0xd815930으로 전송 됨' '잡히지 않은 예외로 인해 앱 종료

- (void)viewDidLoad { 
     [super viewDidLoad]; 

     [self addImageWithName:@"image10.jpg" atPosition:0]; 

     for (int i=1; i< 11; i++) { 
      [self addImageWithName:[NSString stringWithFormat:@"image%i.jpg",i] atPosition:i]; 
     } 

     [self addImageWithName:@"image1.jpg" atPosition:11]; 

     scrollView.contentSize = CGSizeMake(1920, 416); 
     [scrollView scrollRectToVisible:CGRectMake(320, 0, 320, 416) animated:NO]; 
    } 
    -(void)addImageWithName:(NSString *)imageString atPosition:(int)position{ 

     UIImage *image = [UIImage imageNamed:imageString]; 
     UIImageView *imageView = [[UIImage alloc] initWithImage:image]; 

     imageView.frame = CGRectMake(position*320, 0, 320, 416); 
     [scrollView addSubview:imageView]; 
     [imageView release]; 

    } 

나는 내 실수가 어디 있는지 잘 모릅니다

+0

THX와 이것을 대체 할 모든 당신이 맞아요 – Spire

답변

1

이것이 문제입니다.

UIImageView *imageView = [[UIImage alloc] initWithImage:image]; 

UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
3
UIImageView *imageView = [[UIImage alloc] initWithImage:image]; 

는해야

UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; 
1

UIImageView * imageView = [[UIImageView 할당] initWithImage : 이미지];

관련 문제