首页 > 其他 > 详细

UICollectionView数据源方法不调用问题

时间:2016-01-06 17:58:09      阅读:457      评论:0      收藏:0      [点我收藏+]

今天遇到一个关于UICollectionView的问题。

在xib中拖入UICollectionView,设置delegate和dataSource,都配置好了,但是发现,

部分数据源方法不被调用。

#pragma mark UICollectionView delegate and datasource

- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {

    return 1;

}

 

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {

    return 17;

}

 //以上两个方法是被正常调用的

//但是cellForItemAtIndexPath方法不被调用

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *identifier = @"WHHostCollectionCell";

    WHHostCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath]; 

    return cell;

}

 - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

}

 

发现其他方法正常,只有cellForItemAtIndexPath不被调用。查找了好长时间,误打误撞,发现将代码中的

layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;注释掉就可以正常回调了。

至于原因,还不知为什么,按理该行代码不应该影响方法的回调,所以还未确定问题,持续查找原因。

UICollectionView数据源方法不调用问题

原文:http://www.cnblogs.com/guatiantian/p/5106048.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!