2012-01-21 30 views
0

我收到以下錯誤:無法識別的選擇發送到發出

- (UIView *)carousel:(iCarousel *)carousel placeholderViewAtIndex:(NSUInteger)index reusingView:(UIView *)view 
{ 
    UILabel *label = nil; 

    //create new view if no view is available for recycling 
    if (view == nil) 
    { 
     view = [[UIImageView alloc] init]; 
     label = [[UILabel alloc] initWithFrame:view.bounds]; 
     label.backgroundColor = [UIColor clearColor]; 
     label.textAlignment = UITextAlignmentCenter; 
     label.font = [label.font fontWithSize:50.0f]; 
     [view addSubview:label]; 
    } 
    else 
    { 
     label = [[view subviews] lastObject]; 
    } 

    //set label 
    label.text = (index == 0)? @"[": @"]"; 

    return view; 
} 

-[SocialCatalogViewController carousel:placeholderViewAtIndex:]: unrecognized selector sent to instance 0x1296db80 
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SocialCatalogViewController carousel:placeholderViewAtIndex:]: unrecognized selector sent to instance 0x1296db80' 
*** First throw call stack: 
(0x2f3c052 0x30cdd0a 0x2f3dced 0x2f3e083 0x2ea30c9 0x2ea2ce2 0x2f1b25 0x2f1e6c 0x2f25b3 0x2f5863 0x2f1a44 0x2f2a50 0x2edd77 0x352e4b 0x143664e 0x1436941 0x144847d 0x144866f 0x144893b 0x14493df 0x1449986 0x14495a4 0x2e01b9 0x2ea1d4 0x2f3dec9 0x13735c2 0x137355a 0x1418b76 0x141903f 0x14182fe 0x1631a2a 0x2f109ce 0x2ea7670 0x2e734f6 0x2e72db4 0x2e72ccb 0x3349879 0x334993e 0x1370a9b 0x2e06 0x2d75 0x1) 
terminate called throwing an exceptionCurrent language: auto; currently objective-c 

任何想法?

回答

4

嗯,是的。該錯誤表示您傳遞了兩個參數(對於carouselplaceholderViewAtIndex)。然而,該方法實際上是carousel: placeholderViewAtIndex: reusingView:,即取三個參數。所以,只需再通過一個reusingView(或nil,因爲該方法有處理這種情況的邏輯)。

相關問題