2012-05-14 7 views
3

apple beginner here. 저는 현재 nickLockwood가 iCarousel을 공부하고 시도하고 있습니다. Im iCarousel에 이미지를 넣을 계획입니다. 그래서 여기 내하는 .m 및 .H 코드는 다음과 같습니다iCarousel 가져 오기 이미지에 어려움이 있습니다.

//하는 .m

@implementation ViewController 

@synthesize images; 
... 

- (void)awakeFromNib 
{  
    if (self) { 

     //set up carousel data 
     //wrap YES = infinite loop 
     wrap = YES; 

     self.images = [NSMutableArray arrayWithObjects: 
         @"apple.jpg",@"lemon.jpg",@"orange.jpg",@"melon.jpg",@"mango.jpg",nil];  
      } 

} 


- (UIView *)carousel:(iCarousel *)_carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view 
{ 
    if (view == nil) 
{ 

     view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[images objectAtIndex:index]]]; 
} 
    return view; 

} 

// .H 내가 할 코드를 원하는 그래서 30 개 이미지를 추가 할 계획되었다

@interface ViewController : UIViewController <iCarouselDataSource, iCarouselDelegate>{ 

NSMutableArray *images; 
... 
} 
@property (nonatomic,retain) NSMutableArray *images; 
… 
@end 

유지할 수있는. 내 문제는 NSBundle 또는 응용 프로그램 디렉토리에서 이미지를 가져올 수 있기를 원하지만 다른 코드를 시도했지만 회전식 캐 러셀에 이미지가 나타나지 않습니다. 당신의 도움을 주셔서 감사합니다.

+0

위임자와 데이터 소스를 설정 했습니까? 내가 본 것처럼 좋은거야 – adali

+0

예 이미 설정했습니다. – Bazinga

+0

당신의 문제는 무엇입니까? – adali

답변

1

여기 내 iCarousel 앱에서 사용한 몇 가지 코드가 있습니다. 몇 가지 방법이 누락되었습니다. 그래서 여기 있습니다.

#pragma mark iCarousel methods 

- (NSUInteger)numberOfItemsInCarousel:(iCarousel *)carousel 
{ 
    return [items count]; 
} 

- (NSUInteger)numberOfVisibleItemsInCarousel:(iCarousel *)carousel 
{ 
    //limit the number of items views loaded concurrently (for performance reasons) 
    //this also affects the appearance of circular-type carousels 
    return 7; 
} 

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSUInteger)index reusingView:(UIView *)view 
{ 
    view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[items objectAtIndex:index]]]; 
    return view; 

} 

- (NSUInteger)numberOfPlaceholdersInCarousel:(iCarousel *)carousel 
{ 
    //note: placeholder views are only displayed on some carousels if wrapping is disabled 
    return 0; 
} 

- (UIView *)carousel:(iCarousel *)carousel placeholderViewAtIndex:(NSUInteger)index reusingView:(UIView *)view 
{ 
    view = [[UIImageView alloc] initWithImage:[UIImage imageNamed:[items objectAtIndex:index]]]; 
    return view; 

} 

- (CGFloat)carouselItemWidth:(iCarousel *)carousel 
{ 
    //usually this should be slightly wider than the item views 
    return ITEM_SPACING; 
} 

- (CGFloat)carousel:(iCarousel *)carousel itemAlphaForOffset:(CGFloat)offset 
{ 
    //set opacity based on distance from camera 
    return 1.0f - fminf(fmaxf(offset, 0.0f), 1.0f); 
} 

- (CATransform3D)carousel:(iCarousel *)_carousel itemTransformForOffset:(CGFloat)offset baseTransform:(CATransform3D)transform 
{ 
    //implement 'flip3D' style carousel 
    transform = CATransform3DRotate(transform, M_PI/8.0f, 0.0f, 1.0f, 0.0f); 
    return CATransform3DTranslate(transform, 0.0f, 0.0f, offset * carousel.itemWidth); 
} 

- (BOOL)carouselShouldWrap:(iCarousel *)carousel 
{ 
    return wrap; 
} 
- (void)carouselDidEndScrollingAnimation:(iCarousel *)aCarousel 
{  
    [labelDescription setText:[NSString stringWithFormat:@"%@", [descriptions objectAtIndex:aCarousel.currentItemIndex]]]; 
} 

희망이 있습니다.

+0

메인 번들은 어때요? – Bazinga

+0

나중에 추가하고 carousel.type = iCarouselTypeCoverFlow2; 귀하의 viewDidLoad – Mou

+0

이미 완료되었습니다. 내 문제는 NSBundle 또는 카메라 롤에서 이미지를 업로드하는 것입니다. thanks – Bazinga

관련 문제