gsdios / sdcyclescrollview Goto Github PK
View Code? Open in Web Editor NEWAutoscroll Banner. 无限循环图片、文字轮播器。
License: MIT License
Autoscroll Banner. 无限循环图片、文字轮播器。
License: MIT License
如题,刚开始以为是pod的问题,结果发现别的库可以,提示如下
Unable to satisfy the following requirements:
SDCycleScrollView (~> 1.3)
required by Podfile
建议在动画类型下,暴漏小圆点的背景色,因为有的不想用clear color。
Hi, I have faced a problem that, when I choose the new images from the photo library, the view is not updating to new images I've just chosen. Are there any ways to solve it?
运行起来直接奔溃哦
OVER
同一个view开始数据源给1张图片,后面给多张图片 则后面的无法手动滑动了。
尤其是当 SDCycleScrollView 放在tableview中的cell上进行复用时,会频繁切换数据源
建议修改:
(void)setImagesGroup:(NSMutableArray *)imagesGroup
{
_imagesGroup = imagesGroup;
if (self.infiniteLoop) {
_totalItemsCount = imagesGroup.count * 100;
}else{
_totalItemsCount = imagesGroup.count;
}
if (imagesGroup.count != 1) {
[self setAutoScroll:self.autoScroll];
self.mainView.scrollEnabled = YES;
} else {
self.mainView.scrollEnabled = NO;
}
[self setupPageControl];
[self.mainView reloadData];
}
上面这个函数,在横竖屏切换时,可能导致targetIndex > _totalItemCount,导致越界crash。是否用一个内部的变量控制index,而不是根据contentOffset来判断index。
建议暴露scrolltoTop的属性设置
无网络的时候,占位图没有?
Actually,it's not a issue , just a suggestion to make it perfect! if there's just one picture,so it's unnecessary to make it scroll automatically, or someone wanna no scrollable automatically...
SDCycleScrollView如果设置分页控件的样式?和标题、标题背景的样式?
因为我可能点击图片的时候放大图片,放大浏览过程中我可能会自己滚动图片,但是我想让cycleScrollView也同步滚动
图片我想等比例压缩,不是全拉伸的
上次写错了,可以参考https://github.com/kingiol/KDCycleBannerView
很多接口都是开放出来的
(NSArray *)numberOfKDCycleBannerView:(KDCycleBannerView *)bannerView {
return @[[UIImage imageNamed:@"image1"],
@"http://d.hiphotos.baidu.com/image/w%3D2048/sign=ed59838948ed2e73fce9812cb339a08b/58ee3d6d55fbb2fb9835341f4d4a20a44623dca5.jpg",
@"http://d.hiphotos.baidu.com/image/w%3D2048/sign=5ad7fab780025aafd33279cbcfd5aa64/8601a18b87d6277f15eb8e4f2a381f30e824fcc8.jpg",
@"http://e.hiphotos.baidu.com/image/w%3D2048/sign=df5d0b61cdfc1e17fdbf8b317ea8f703/0bd162d9f2d3572c8d2b20ab8813632763d0c3f8.jpg",
@"http://d.hiphotos.baidu.com/image/w%3D2048/sign=a11d7b94552c11dfded1b823571f63d0/eaf81a4c510fd9f914eee91e272dd42a2934a4c8.jpg"];
}
(UIViewContentMode)contentModeForImageIndex:(NSUInteger)index {
return UIViewContentModeScaleAspectFill;
}
(UIImage *)placeHolderImageOfZeroBannerView {
return [UIImage imageNamed:@"image1"];
}
$ pod search SDCyclescrollview
[!] Unable to find a pod with name matching `SDCyclescrollview'
有get和save了。建议加个clear。用于清理缓存。
图片缓存是无效的
RT
当数据源数量为1时 暂无设置控制pagecontrol隐藏的功能
由于我自己项目需要 我暂时建议的修改如下
(void)setupPageControl
{
if (_pageControl) [_pageControl removeFromSuperview]; // 重新加载数据时调整
if (_imagesGroup.count <=1) {
_pageControl = nil;
return;
}
TAPageControl *pageControl = [[TAPageControl alloc] init];
pageControl.numberOfPages = self.imagesGroup.count;
pageControl.dotColor = self.dotColor;
[self addSubview:pageControl];
_pageControl = pageControl;
}
希望主维护人员有时间的话能讲 自定义的pagecontrol换成系统自带的,并提供对应接口 控制数据源数量为1时是否隐藏功能,另希望能将项目配置为支持cocoapods的让更多人有更多的选择使用方式,非常感谢您分享的这个项目,希望能持续更新优化超越同类的第三方。
如题
修改为
typedef NS_ENUM(NSInteger, SDCycleScrollViewPageContolStyle) {
SDCycleScrollViewPageContolStyleClassic, // 系统自带经典样式
SDCycleScrollViewPageContolStyleAnimated, // 动画效果pagecontrol
SDCycleScrollViewPageContolStyleNone // 不显示pagecontrol
};
容易出现-[__NSCFString absoluteURL]: 错误
一般出现这种情况,是在请求图片的时候,把NSURL连接直接用NSString 拼接了。 偶尔你用NSString拼接不会出现error,但是会莫名其妙的出现这样的问题,所以在用到请求图片的时候一定注意
建议改为如下:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", self.imageURLsGroup[index]]];
//NSURL *url = self.imageURLsGroup[index];
//网络加载 --- 创建带标题的图片轮播器
// SDCycleScrollView *cycleScrollView2 = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 320, w, 180) imageURLStringsGroup:imagesURLStrings];
SDCycleScrollView *cycleScrollView2 = [[SDCycleScrollView alloc] initWithFrame:CGRectMake(0, 320, w, 180)];
cycleScrollView2.pageControlAliment = SDCycleScrollViewPageContolAlimentRight;
cycleScrollView2.delegate = self;
cycleScrollView2.titlesGroup = titles;
cycleScrollView2.dotColor = [UIColor yellowColor]; // 自定义分页控件小圆标颜色
cycleScrollView2.placeholderImage = [UIImage imageNamed:@"placeholder"];
[self.view addSubview:cycleScrollView2];
cycleScrollView2.imageURLStringsGroup = imagesURLStrings;
很多时候开始时是不知道网络url的,基本先创建了view占位,当网络请求后拿到url时再赋值的,此时无法显示图片,或者切换显示图片显示的url源和个数时 显示的个数不对
建议 _totalItemsCount 跟 imagesGroup 和 infiniteLoop形成绑定关系
(void)setImagesGroup:(NSMutableArray *)imagesGroup
{
_imagesGroup = imagesGroup;
_totalItemsCount = self.infiniteLoop ? imagesGroup.count * 100 : imagesGroup.count;
if (imagesGroup.count != 1) {
if (self.autoScroll) {
[self setupTimer];
}
} else {
self.mainView.scrollEnabled = NO;
}
[self setupPageControl];
[self.mainView reloadData];
}
而不是 和 是否加到 父视图形成绑定关系
改的这个 flowLayout.minimumLineSpacing = 50; 兄弟有空的话指点下哈
你好,在StoryBoard中试了试,始终无法显示。
1.回到后台后,没有设置不滚动。
2.如果设置滚动速率?
我尝试加了一个判断
2015-06-04 02:08:46.639 ws[5431:1452099] the behavior of the UICollectionViewFlowLayout is not defined because:
2015-06-04 02:08:46.642 ws[5431:1452099] the item height must be less than the height of the UICollectionView minus the section insets top and bottom values.
2015-06-04 02:08:56.613 ws[5431:1452099] *** -[SDCycleScrollView scrollViewDidScroll:]: message sent to deallocated instance 0x1a865630
viewcontroller 设置为 UIRectEdgeAll时, 添加的轮播视图 头部会多出 空白区域
RT
Get below message when the controller is embed in navigation controller, please check it:
"The behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less than the height of the UICollectionView minus the section insets top and bottom values."
如果SDCycleScrollView已经放到一个view里,代码运行时设置pageControlDotSize属性不起作用,swift中使用
创建SDCycleScrollView的代码
let imgs = Array(arrayLiteral: "1.jpg","2.jpg","3.jpg","4.jpg","5.jpg","6.jpg")
let scv = SDCycleScrollView(frame: CGRect(x: 0, y: 44, width: UIScreen.mainScreen().bounds.width, height: 400), imagesGroup: imgs)
self.view.addSubview(scv)
出错的位置:
//if语句出错
if (image.size.width == 0 && self.placeholderImage) {
image = self.placeholderImage;
}
cell.imageView.image = image;
if (_titlesGroup.count) {
cell.title = _titlesGroup[itemIndex];
}
RT,我还是新手,我在尝试增加这个功能,但是本身的技术难以达到,希望作者可以考虑考虑
我的环境是xcode6.4 iOS sdk 8.4, 图片全部对应的设置了标题,显示时,有的显示了,有的不显示,
如图:(第一个没有,第二个又有了)
自己调试了下,发现是collection view的cell布局问题,没有调用layoutsubviews方法,于是在- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath里加入下面两句:
[cell setNeedsLayout];
[cell layoutIfNeeded];
问题解决了。
when the controller is embed in navigation controller, and push pop several times Get below message and app crashed. please check it:
"The behavior of the UICollectionViewFlowLayout is not defined because: the item height must be less than the height of the UICollectionView minus the section insets top and bottom values."
[cycleScrollView2 clearCache] 应该学习sdwebImage,单例清除,而且是全局的
RT
如何传入一个参数 固定到指定位置图片 然后不循环播放 自己改动后 加入一个参数值 但是图片不循环后有问题 初始图片不能往左划
多次(1一次以上)给imageURLsGroup
和titlesGroup
赋值后,会导致滚动时间变短,滚动得很快!
初始化:
CGRect _adBannerViewFrame = self.view.bounds;
_adBannerViewFrame.size.height = 200.0;
_adBannerView = [[SDCycleScrollView alloc] initWithFrame:_adBannerViewFrame];
_adBannerView.delegate = self;
取得数据后赋值,这段代码调用两次(包含两次)以上就会出现滚动时间变短的问题
_adBannerView.imageURLsGroup = imageUrls;
_adBannerView.titlesGroup = titles;
_tableView.tableHeaderView = _adBannerView;
感谢这个控件,我从中学习了不少东西,尤其是线程和缓存.同时发现了一些问题,仅供您参考.
1.timer的invalidate有疏漏
-(void)setAutoScrollTimeInterval:(CGFloat)autoScrollTimeInterval
{
_autoScrollTimeInterval = autoScrollTimeInterval;
[self setupTimer];
}
每设置一次autoScrollTimeInterval就会多一个timer.
同理还有这里 - (void)setImagesGroup:(NSMutableArray *)imagesGroup.
在setupTimer中一次性加上其他地方写过的
[_timer invalidate];
_timer = nil;
2.建议用约束写collectionView和pageControl,就能在xib中用约束直接这个控件;
3.建议增加placeholderImage和pageControlBackgroundColor属性.
4..pageControl的valuechange事件也可以带动scrollView的滚动
试用了你的这个项目几天,还不错,就是分页控件的样式还是怪怪的,看了你的源码是自己写的分页控件,xcode默认的那个分页控件的样式看起来很清爽,请支持使用默认的分页控件样式。
网络图片一下子全下载下来了,浪费流量哇
用的是网络图片。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.