You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
80 lines
2.7 KiB
80 lines
2.7 KiB
1 year ago
|
//
|
||
|
// CarouselViewCell.m
|
||
|
// tongxin
|
||
|
//
|
||
|
// Created by Apple on 2020/4/8.
|
||
|
// Copyright © 2020 xTT. All rights reserved.
|
||
|
//
|
||
|
|
||
|
#import "CarouselViewCell.h"
|
||
|
#import "User.h"
|
||
|
#import "WebViewController.h"
|
||
|
|
||
|
@implementation CarouselViewCell
|
||
|
|
||
|
- (void)awakeFromNib {
|
||
|
[super awakeFromNib];
|
||
|
// Initialization code
|
||
|
self.selectionStyle = UITableViewCellSelectionStyleNone;
|
||
|
self.contentView.backgroundColor = [UIColor clearColor];
|
||
|
self.backgroundColor = [UIColor clearColor];
|
||
|
|
||
|
_tempCarouselView = [[XRCarouselView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenWidth*0.4)];
|
||
|
[self addSubview:_tempCarouselView];
|
||
|
//加载轮播图 如果没加载到,就是使用默认的 img_banner
|
||
|
_tempCarouselView.placeholderImage = [UIImage imageNamed:@"img_banner"];
|
||
|
/*
|
||
|
2.changeMode:图片切换方式,有轮播滚动与淡入淡出两种
|
||
|
|
||
|
3.describeArray:图片描述的字符串数组,应与图片顺序对应
|
||
|
|
||
|
4.time:设置每页的停留时间
|
||
|
|
||
|
5.void(^imageClickBlock)(NSInteger index):图片被点击后要执行的代码
|
||
|
*/
|
||
|
_tempCarouselView.changeMode = ChangeModeFade;
|
||
|
_tempCarouselView.time = 5.0f;
|
||
|
_tempCarouselView.imageArray = @[[UIImage imageNamed:@"img_banner"]];
|
||
|
}
|
||
|
|
||
|
|
||
|
- (void)setData:(NSArray<SlideshowModel *> *)modelArr WithPlaceholderImage:(NSString *)pImage{
|
||
|
_modelArr = modelArr;
|
||
|
_tempCarouselView.placeholderImage = [UIImage imageNamed:pImage];
|
||
|
if (modelArr && modelArr.count > 0){
|
||
|
NSMutableArray *tempImageURLArr = [NSMutableArray array];
|
||
|
for (SlideshowModel *model in modelArr) {
|
||
|
[tempImageURLArr addObject:model.image];
|
||
|
}
|
||
|
_tempCarouselView.imageArray = tempImageURLArr;
|
||
|
WEAKSELF
|
||
|
_tempCarouselView.imageClickBlock = ^(NSInteger index) {
|
||
|
SlideshowModel *model = weakSelf.modelArr[index];
|
||
|
|
||
|
|
||
|
[cUser postSlideshowInfoWithID:model.id Success:^(id responseObject) {
|
||
|
xLog(@"点击轮播图 ID:%@ name:%@, url:%@",model.id,model.title,model.url);
|
||
|
} failure:^(id faiObject) {
|
||
|
xLog(@"点击轮播图上传失败");
|
||
|
}];
|
||
|
if([model.url containsString:@"://"]){
|
||
|
WebViewController *vc = [WebViewController new];
|
||
|
vc.url = model.url;
|
||
|
vc.title = model.title;
|
||
|
vc.hidesBottomBarWhenPushed = YES;
|
||
|
// vc.isHiddenNavigationBar = YES;
|
||
|
[weakSelf.getViewController.navigationController pushViewController:vc animated:YES];
|
||
|
}
|
||
|
};
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
|
||
|
[super setSelected:selected animated:animated];
|
||
|
|
||
|
// Configure the view for the selected state
|
||
|
}
|
||
|
|
||
|
@end
|