Giter Site home page Giter Site logo

12207480 / tycyclepagerview Goto Github PK

View Code? Open in Web Editor NEW
1.8K 28.0 324.0 1.36 MB

a simple and usefull cycle pager view ,and auto scroll banner view(轮播图) ,include pageControl for iOS,support Objective-C and swift

License: MIT License

Objective-C 87.96% Swift 10.72% Ruby 1.32%
pager cycle banner autoscrolling pagecontrol

tycyclepagerview's People

Contributors

12207480 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

tycyclepagerview's Issues

有个警告This is likely occurring because the flow layout...

This is likely occurring because the flow layout subclass SXLineLayout is modifying attributes returned by UICollectionViewFlowLayout without copying them

需要修改为

  • (NSArray<UICollectionViewLayoutAttributes *> *)layoutAttributesForElementsInRect:(CGRect)rect {
    NSArray *attributesArray = [[NSArray alloc] initWithArray:[super layoutAttributesForElementsInRect:rect] copyItems:YES];
    if (_delegateFlags.applyTransformToAttributes || _layout.layoutType != TYCyclePagerTransformLayoutNormal) {
    CGRect visibleRect = {self.collectionView.contentOffset,self.collectionView.bounds.size};
    for (UICollectionViewLayoutAttributes *attributes in attributesArray) {
    if (!CGRectIntersectsRect(visibleRect, attributes.frame)) {
    continue;
    }
    if (_delegateFlags.applyTransformToAttributes) {
    [_delegate pagerViewTransformLayout:self applyTransformToAttributes:attributes];
    }else {
    [self applyTransformToAttributes:attributes layoutType:_layout.layoutType];
    }
    }
    }
    return attributesArray;
    }

pagecontrol 的点点算法错误

在 layoutIndicatorViews
{
case UIControlContentHorizontalAlignmentCenter:
orignX = (CGRectGetWidth(self.frame) - (_indicatorViews.count - 1) * (_pageIndicatorSize.width + _pageIndicatorSpaing) - _currentPageIndicatorSize.width )/2;

for ()
{
indicatorView.frame = CGRectMake(orignX , centerY - size.height/2, size.width, size.height);

    orignX += size.width + pageIndicatorSpaing;

}
}

滚动cell 向下偏移?

有两句警告
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, minus the content insets top and bottom values.

iOS 11 have memory leak problem

when i run on iOS 11 fps is low and then i use analyze to check maybe have memory leak
i try to solove but i can't so write this issues
thanks

布局

不提供设置圆点常规颜色和选中颜色的接口吗?

你好,可以在cell 里面修改item 的size吗?改如何修改?

我这里的需求是根据cell 的高度来计算item 的高度,但是第一如何获取到pageView ?后来我尝试获取到当前的控制器,然后拿到当前的pageView ,如下代码:
_pagerView.layout.itemSize = CGSizeMake(CGRectGetWidth(_pagerView.frame)*sender.value, CGRectGetHeight(_pagerView.frame)*sender.value);
[_pagerView setNeedUpdateLayout];
但是我发现跑起来,没有改变,并且一滑动,这个布局都乱了。。。求助大,大神!!!

可以加qq 吗?我的qq 是704379869

延时加载数据"循环"和"居中"不正常

  • (void)loadData {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    NSMutableArray *datas = [NSMutableArray array];
    for (int i = 0; i < 5; ++i) {
    if (i == 0) {
    [datas addObject:[UIColor redColor]];
    continue;
    }
    [datas addObject:[UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:arc4random()%255/255.0]];
    }
    _datas = [datas copy];
    // _pageControl.numberOfPages = _datas.count;
    [_pagerView reloadData];
    });

}

  • (TYCyclePagerViewLayout *)layoutForPagerView:(TYCyclePagerView *)pageView {
    TYCyclePagerViewLayout *layout = [[TYCyclePagerViewLayout alloc]init];
    layout.layoutType = TYCyclePagerTransformLayoutLinear;
    layout.itemSpacing = 45;
    layout.minimumAlpha = 0.0;
    layout.itemHorizontalCenter = YES;
    layout.itemSize = CGSizeMake(200, CGRectGetHeight(pageView.frame));
    return layout;
    }

这样设置会有BUG,

单个图片

如果设置了圆角 此时banner只有一个数据 两边的图片还显示同一图片
而且手动还能滚动 滚动以后还不能居中

关于pageControl部分

在设置pageControl.currentPageIndicatorSize的大小和pageIndicatorSize宽度大小不一致的时候,能否保持他们之间的间距不变

ios 11 环境下 页面无法滚动

获取数据之后调用[pagerView reloadData]方法,页面显示正常,但手动滚动的话,会自动滚回来,
ios 11以下正常运行

询问一下计算是否有误

在 - caculateIndexSectionWithOffsetX 方法中,计算 itemIndex 的算法里
代码是这样的 NSInteger itemIndex = (middleOffset - leftEdge + layout.minimumInteritemSpacing / 2) / itemWidth;
其中的 + layout.minimumInteritemSpacing / 2 是否应该改成 - layout.itemSize.width / 2 ?

期待你的回复

scrollToItemAtIndex:animate无效

初始化时 scrollToItemAtIndexSection:animate: 调用了三次 有效的是第二次 第三次又将偏移量设置为0了。需要延迟设置scrollToItemAtIndex:animate方法才能有效果

延时加载数据后,无法滚动

用demo运行,ViewController里用延时加载的loadData方法,无法拖动cell。如果将numberOfItemsInPagerView返回值改为固定值则可拖动。

reloadData 之后直接调用 scrollToItemAtIndex 无效问题

-(void)loadData {
    NSMutableArray *datas = [NSMutableArray array];
    for (int i = 0; i < 7; ++i) {
        if (i == 0) {
            [datas addObject:[UIColor redColor]];
            continue;
        }
        [datas addObject:[UIColor colorWithRed:arc4random()%255/255.0 green:arc4random()%255/255.0 blue:arc4random()%255/255.0 alpha:arc4random()%255/255.0]];
    }
    _datas = [datas copy];
    _pageControl.numberOfPages = _datas.count;
    [_pagerView reloadData];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
         [_pagerView scrollToItemAtIndex:3 animate:YES];
    });
 
}

当我初始化数据完成,想要滚动到指定的index,这时候调用scrollToItemAtIndex 失效,因为layoutSubviews 时候重置了contentOffset,目前是加了个延迟,但是路子有点野,请问有更好的方式没有?

请问可以通过什么方式来阻止复用的问题?

我的轮播cell里面由3个UIImageView和1个AVPlayer, AVPlayer的播放layer在UIImageView上面.
现在遇到的问题是重复轮播几遍之后3个UIImageView上面都播放了视频,
http://ww1.sinaimg.cn/large/0061KoHBgy1fpofm8uwfrj30q217g4nm.jpg
感谢.

## pagerView delegate

- (UICollectionViewCell *)pagerView:(TYCyclePagerView *)pagerView cellForItemAtIndex:(NSInteger)index {
    JTZbannerCell *cell = [pagerView dequeueReusableCellWithReuseIdentifier:@"JTZbannerCell" forIndex:index];

    NSString *type = self.bannerDataSource[index];
    
    cell.type = type;

    return cell;
}

## setType

- (void)setType:(NSString *)type {
    _type = type;

    if ([type containsString:@"mp4"]) {
        [self playerLayer];
        [self.player play];
    } else {
        [self.imageView setImageWithURLString:type placeholderImageName:@"home_p_bg"];
    }
}

numberOfItemsInPagerView 初始化时调用了至少20次。

  • (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    // _numberOfItems = [_dataSource numberOfItemsInPagerView:self];
    return _numberOfItems;
    }

这出我隐藏掉了。 也能满足要求

UIViewcontroller实现UIScrollViewDelegate的scrollViewDidScroll方法,导致TYCyclePagerView崩溃

我在UIViewcontroller实现UIScrollViewDelegate的scrollViewDidScroll方法,使用了TYCyclePagerView之后,一运行就崩溃,报错原因是reason: '-[AHHomeViewController pagerViewDidScroll:]: unrecognized selector sent to instance 0x7ff0d5631cf0'。

我看了一下源码,在TYCyclePagerView.m文件的setDelegate:方法里面,
_delegateFlags.pagerViewDidScroll = [delegate respondsToSelector:@selector(scrollViewDidScroll:)]
此处是检查delegate是否实现了scrollViewDidScroll:方法,然后在TYCyclePagerView.m 文件里面实现的scrollViewDidScroll方法里面判断_delegateFlags.pagerViewDidScroll是否为真,然后调用的[_delegate pagerViewDidScroll:self]。
如果UIViewcontroller并没有实现pagerViewDidScroll,而只是实现scrollViewDidScroll:方法,就会导致崩溃现象。所以需要修改为
_delegateFlags.pagerViewDidScroll = [delegate respondsToSelector:@selector(pagerViewDidScroll:)]

圆角

有设置圆角的接口吗,让其类似卡片播放的效果?

崩溃问题

用到此框架做轮播的页面如果 实现 - (void)scrollViewDidScroll:(UIScrollView *)scrollView 这个代理方法就会崩溃呢?

希望支持纵向

非常好的轮播 ,别的轮播都是设计好了几个样式,供选择,局限性大。而你的是把cell 交给了程序员自己去设计,可扩展性很强。需求需要,希望支持纵向。

1.多次点击item 在item滚动的时候会被打断

解决办法 将tycyclepageview 中的 setcontentoffset:offset animation :animation 改成
[UIView animateWithDuration:0.2 animations:^{
_collectionView.contentOffset = CGPointMake(offset, _collectionView.contentOffset.y);
}];

崩溃问题

你好,如果我在某个页面用到了轮播,但是这个页面需要在- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{

}
这个方法里做某些事情,只要用到你的框架实现轮播的页面实现- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{

}这个代理方法就会崩溃呢?

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.