12207480 / TYPagerController

page scroll view and controller,simple,high custom,and have many tabBar styles,,support Objective-C and swift
MIT License
1.37k stars 232 forks source link

我用自定义的CollectionCell作为tabPagerBar的item,里面有一个button,但是永远只能显示当前index的那个CollectionCell,另外两个size为{0,0} #71

Closed shenguanjiejie closed 6 years ago

shenguanjiejie commented 6 years ago

配置代码如下: ` _tabBar = [[TYTabPagerBar alloc]init]; _tabBar.layout.barStyle = TYPagerBarStyleNoneView; _tabBar.dataSource = self; _tabBar.delegate = self; _tabBar.layout.cellWidth = kScreenWidth / 3; _tabBar.layout.progressHeight = 0; _tabBar.layout.cellSpacing = 0; [_tabBar registerClass:[RJButtonCCell class] forCellWithReuseIdentifier:@"CELL"]; [self.view addSubview:_tabBar];

_pageController = [[TYPagerController alloc]init];
_pageController.layout.prefetchItemCount = 5;
_pageController.layout.progressAnimateEnabel = YES;

// pagerController.layout.autoMemoryCache = NO; // 只有当scroll滚动动画停止时才加载pagerview,用于优化滚动时性能 _pageController.layout.addVisibleItemOnlyWhenScrollAnimatedEnd = NO; _pageController.dataSource = self; _pageController.delegate = self; [self addChildViewController:_pageController]; [self.view addSubview:_pageController.view]; `

`

pragma mark - TYPagerControllerDelegate

-(void)pagerController:(TYPagerController *)pagerController transitionFromIndex:(NSInteger)fromIndex toIndex:(NSInteger)toIndex progress:(CGFloat)progress { [_tabBar scrollToItemFromIndex:fromIndex toIndex:toIndex progress:progress]; } ` 显示效果:

screen shot 2017-11-10 at 11 53 28

shenguanjiejie commented 6 years ago

如果我把 _pageController.layout.progressAnimateEnabel 设置为NO,那么就会只有第一个Cell的frame是正确的,滑动到另外两个页面,Cell不出现,我用xcode的debug navigator看,确实是有3个cell的,只是另外两个的size永远是{0,0}

12207480 commented 6 years ago

demo 发给我看看

shenguanjiejie commented 6 years ago

@12207480 demo写好了 你看一下 我想要的效果是三个图片本来就一起显示出来,但是现在不行,只能有一个显示出来 https://github.com/shenguanjiejie/TYPagerControllerDemo.git

shenguanjiejie commented 6 years ago

看这个demo,是不是代理方法必须返回一个遵守TYTabPagerBarCellProtocol协议的CollectionCell有点奇怪了? 不知道能不能去掉这个限制

12207480 commented 6 years ago
shenguanjiejie commented 6 years ago

😂 好吧 是我傻叉了... 关掉了