码迷,mamicode.com
首页 > 其他好文 > 详细

ICarousel第三方库的使用示例

时间:2015-09-13 20:03:02      阅读:326      评论:0      收藏:0      [点我收藏+]

标签:

1.创建

技术分享
_carousel = [[iCarousel alloc] initWithFrame:CGRectMake(0, 0, 375, 250)];
    _carousel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
    _carousel.type = iCarouselTypeRotary;
    _carousel.delegate = self;
    _carousel.dataSource = self;
    _carousel.tag = 200;
    [_headView addSubview:_carousel];
View Code

2.代理方法

技术分享
#pragma mark --iCarousel methods

- (NSInteger)numberOfItemsInCarousel:(iCarousel *)carousel
{
    return [_topData count];
}

- (UIView *)carousel:(iCarousel *)carousel viewForItemAtIndex:(NSInteger)index reusingView:(UIView *)view
{
    if (view == nil)
    {
        view = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0,150, 250)];
        view.contentMode = UIViewContentModeCenter;
    }
    TopScrollModel *model = _topData[index];
    [((UIImageView *)view) sd_setImageWithURL:[NSURL URLWithString:model.poster_url] placeholderImage:[UIImage imageNamed:@"placeImg"]];
    return view;
}

#pragma mark --ICarouselScrollView---
-(void)carouselDidEndScrollingAnimation:(iCarousel * __nonnull)carousel
{
    if (carousel.currentItemIndex == -1) {
        return;
    }
    [self showTopLabelData:carousel.currentItemIndex];
    //NSLog(@"%li",carousel.currentItemIndex);
}

-(void)carousel:(iCarousel * __nonnull)carousel didSelectItemAtIndex:(NSInteger)index
{
    MovieDetailController *mvc = [[MovieDetailController alloc] init];
    mvc.movieId = [_topData[index] valueForKey:@"movieId"];
    mvc.type = MovieDidPaly;
    mvc.titleStr = [_topData[index] valueForKey:@"name"];
    self.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:mvc animated:YES];
    self.hidesBottomBarWhenPushed = NO;
}
View Code

 

ICarousel第三方库的使用示例

标签:

原文地址:http://www.cnblogs.com/liaods/p/4805436.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!