先用cocopods导入SDWebImage
#import "SportView.h"
#import "SDCycleScrollView.h"
#import "Scrollview.h"
#import "UIImageView+WebCache.h"
@interface SportView ()
{ UITableView*table;
NSArray*_imagesURLStrings;
SDCycleScrollView*_customCellScrollViewDemo;
NSMutableArray*datasource;
}
@end
@implementation SportView
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor=[UIColor orangeColor];
table=[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStylePlain];
table.dataSource=self;
table.delegate=self;
[self.view addSubview:table];
datasource=[[NSMutableArray alloc]init];
}
-(NSInteger)tableView:(UITableView*)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section{
UIView *view=[[UIView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 180)];
[self.view addSubview:view];
UIScrollView *demoContainerView = [[UIScrollView alloc] initWithFrame:self.view.frame];
demoContainerView.contentSize = CGSizeMake(self.view.frame.size.width, 1200);
[self.view addSubview:demoContainerView];
NSArray*imagesURLStrings =@[
@"http://cms-bucket.nosdn.127.net/2018/12/02/37a206386db24278b1b81d835dbca713.jpeg",
@"http://cms-bucket.nosdn.127.net/2018/12/02/64c6292031b64f628255fe40813a05c1.png",
@"http://cms-bucket.nosdn.127.net/2018/12/02/1dfff0110f334df5bd1cdebb7f0540c5.png"
,@"http://cms-bucket.nosdn.127.net/2018/12/02/b6ffbb865824418788d1fbe476e46cfd.png",
@"http://cms-bucket.nosdn.127.net/2018/12/02/ae3401d0d0654268b4c8b31cb935fe21.png"];
_imagesURLStrings= imagesURLStrings;
CGFloat w = self.view.bounds.size.width;
// 网络加载 --- 创建自定义图片的pageControlDot的图片轮播器
SDCycleScrollView *cycleScrollView3 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, w, 180) delegate:self placeholderImage:[UIImage imageNamed:@"placeholder"]];
cycleScrollView3.currentPageDotImage= [UIImageimageNamed:@"pageControlCurrentDot"];
cycleScrollView3.pageDotImage= [UIImageimageNamed:@"pageControlDot"];
cycleScrollView3.imageURLStringsGroup= imagesURLStrings;
[view addSubview:cycleScrollView3];
return view;
}
-(UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"cell"];
if( cell==nil) {
cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
}
return cell;
}
-(CGFloat)tableView:(UITableView*)tableView heightForRowAtIndexPath:(NSIndexPath*)indexPath{
return 180;
}
@end
这个第三方文件中,存储网络地址的数组必须是NSArray;
详情,请到 https://github.com/gsdios/SDCycleScrollView 。
我只是截取一段。里面有更好内容。
我只是转载,请勿说模仿