Git Product home page Git Product logo

sdcyclescrollview's People

Contributors

cocoa-chen avatar gsdios avatar kyoooooo avatar weike9786 avatar zohar163 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sdcyclescrollview's Issues

pod 安装失败

如题,刚开始以为是pod的问题,结果发现别的库可以,提示如下
Unable to satisfy the following requirements:

  • SDCycleScrollView (~> 1.3) required by Podfile

Images cannot update

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?

重置数据源时 如果刚开始的图片数为1 后面的为多张 后面的无法手动滑动

同一个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];
    }

一个潜在bug,导致越界crash

  • (void)automaticScroll
    {
    if (0 == _totalItemsCount) return;
    int currentIndex = _mainView.contentOffset.x / _flowLayout.itemSize.width;
    int targetIndex = currentIndex + 1;
    if (targetIndex == _totalItemsCount) {
    if (self.infiniteLoop) {
    targetIndex = _totalItemsCount * 0.5;
    }else{
    targetIndex = 0;
    }
    [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
    }
    [_mainView scrollToItemAtIndexPath:[NSIndexPath indexPathForItem:targetIndex inSection:0] atScrollPosition:UICollectionViewScrollPositionNone animated:YES];
    }

上面这个函数,在横竖屏切换时,可能导致targetIndex > _totalItemCount,导致越界crash。是否用一个内部的变量控制index,而不是根据contentOffset来判断index。

再次进入控制器不能手动滑动

初始化进入控制器的时候可以滑动,但是跳转到别下个控制器,再次回来,就不能手动滑动了。

我把红框那句代码加上就好了

snip20150704_1

如何自动滚动到那一页?还有能够设定图片的缩放类型

因为我可能点击图片的时候放大图片,放大浏览过程中我可能会自己滚动图片,但是我想让cycleScrollView也同步滚动
图片我想等比例压缩,不是全拉伸的

上次写错了,可以参考https://github.com/kingiol/KDCycleBannerView
很多接口都是开放出来的

pragma mark - KDCycleBannerViewDataSource

  • (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"];
    }

pragma mark - KDCycleBannerViewDelegate

  • (void)cycleBannerView:(KDCycleBannerView *)bannerView didScrollToIndex:(NSUInteger)index {
    NSLog(@"didScrollToIndex:%ld", (long)index);
    }
  • (void)cycleBannerView:(KDCycleBannerView *)bannerView didSelectedAtIndex:(NSUInteger)index {
    NSLog(@"didSelectedAtIndex:%ld", (long)index);
    }

当数据源数量为1时 暂无设置控制pagecontrol隐藏的功能

当数据源数量为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的让更多人有更多的选择使用方式,非常感谢您分享的这个项目,希望能持续更新优化超越同类的第三方。

SDCycleScrollViewPageContolStyleClassic

如题
修改为
typedef NS_ENUM(NSInteger, SDCycleScrollViewPageContolStyle) {
SDCycleScrollViewPageContolStyleClassic, // 系统自带经典样式
SDCycleScrollViewPageContolStyleAnimated, // 动画效果pagecontrol
SDCycleScrollViewPageContolStyleNone // 不显示pagecontrol
};

建议SDCycleScrollView下loadImageAtIndex函数这里改下

容易出现-[__NSCFString absoluteURL]: 错误
一般出现这种情况,是在请求图片的时候,把NSURL连接直接用NSString 拼接了。 偶尔你用NSString拼接不会出现error,但是会莫名其妙的出现这样的问题,所以在用到请求图片的时候一定注意
建议改为如下:
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@", self.imageURLsGroup[index]]];
//NSURL *url = self.imageURLsGroup[index];

先创建view 添加到父view后再复制网络图片 无法显示

 //网络加载 --- 创建带标题的图片轮播器

// 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];
    }

而不是 和 是否加到 父视图形成绑定关系

  • (void)willMoveToSuperview:(UIView *)newSuperview
    {
    if (!newSuperview) {
    [_timer invalidate];
    _timer = nil;
    } else {
    _totalItemsCount = self.infiniteLoop ? self.imagesGroup.count * 100 : self.imagesGroup.count;
    }
    }

bug

1.回到后台后,没有设置不滚动。
2.如果设置滚动速率?

本地或者网络设置显示一张图片的时候显示会有问题

我尝试加了一个判断

  • (void)setImagesGroup:(NSMutableArray *)imagesGroup
    {
    _imagesGroup = imagesGroup;
    _totalItemsCount = imagesGroup.count * 100;
    if (_imagesGroup.count == 1) {
    _mainView.scrollEnabled = NO;
    return;
    }
    [self setupTimer];
    [self setupPageControl];
    [self.mainView reloadData];
    }

NSURLConnection 已弃用 请用NSURLSession

  • (nullable instancetype)initWithRequest:(NSURLRequest *)request delegate:(nullable id)delegate startImmediately:(BOOL)startImmediately NS_DEPRECATED(10_5, 10_11, 2_0, 9_0, "Use NSURLSession (see NSURLSession.h)");

message sent to deallocated instance

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

在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)

出错的位置:

  • (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
    {
    SDCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:ID forIndexPath:indexPath];
    long itemIndex = indexPath.item % self.imagesGroup.count;
    UIImage *image = self.imagesGroup[itemIndex];

//if语句出错
if (image.size.width == 0 && self.placeholderImage) {
image = self.placeholderImage;
}
cell.imageView.image = image;
if (_titlesGroup.count) {
cell.title = _titlesGroup[itemIndex];
}

多图片标题不显示问题

我的环境是xcode6.4 iOS sdk 8.4, 图片全部对应的设置了标题,显示时,有的显示了,有的不显示,
如图:(第一个没有,第二个又有了)
qq20150731-1
qq20150731-3
自己调试了下,发现是collection view的cell布局问题,没有调用layoutsubviews方法,于是在- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath里加入下面两句:
[cell setNeedsLayout];
[cell layoutIfNeeded];
问题解决了。

the behavior of the UICollectionViewFlowLayout is not defined

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,单例清除,而且是全局的

滚动时间间隔变短

多次(1一次以上)给imageURLsGrouptitlesGroup赋值后,会导致滚动时间变短,滚动得很快!

初始化:

 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默认的分页控件样式吗?

试用了你的这个项目几天,还不错,就是分页控件的样式还是怪怪的,看了你的源码是自己写的分页控件,xcode默认的那个分页控件的样式看起来很清爽,请支持使用默认的分页控件样式。

流量思考

网络图片一下子全下载下来了,浪费流量哇

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.