大佬教程收集整理的这篇文章主要介绍了ios – 奇怪的UICollectionView选择行为,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我填写的静态数据:
self.menuItems = @[@{@"text" : @"First",@"image" : @"180-stickynote.png"},@{@"text" : @"Second",@{@"text" : @"Third",@{@"text" : @"Fourth",@{@"text" : @"Fifth",@{@"text" : @"Sixth",@"image" : @"180-stickynote.png"}];
和单元格提供程序,其中自定义子类附加到原型单元格,并具有UILabel和UIImageView:
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemATindexPath:(NSIndexPath *)indexPath { CUMenuCollectionViewCell *cell = [collectionView dequeueReusableCellWithReusEIDentifier:@"MenuCell" forIndexPath:indexPath]; NSDictionary *cellInfo = [self.menuItems objectATindex:indexPath.row]; cell.imageView.image = [UIImage imagenamed:[cellInfo valueForKey:@"image"]]; cell.label.text = [cellInfo valueForKey:@"text"]; return cell; }
- (void)collectionView:(UICollectionView *)collectionView didDeSELEctItemATindexPath:(NSIndexPath *)indexPath { NSLog(@"%@: %d",[[self.menuItems objectATindex:indexPath.row] valueForKey:@"text"],indexPath.row); }
最后,我的菜单的屏幕截图:
这是从第一到第六,从第六到第一(第一,第二,第三,第四,第五,第六,第一)的项目的日志(共12个抽头,注意,第一个水龙头甚至没有注册,第六个水龙头也没有):
------------------------------------- FIRST TAP ON FIRST HERE 2013-02-13 19:38:37.343 App[1383:c07] First: 0 // second tap,on Second 2013-02-13 19:38:38.095 App[1383:c07] Second: 1 // third tap,on Third 2013-02-13 19:38:38.678 App[1383:c07] Third: 2 // fourth tap,on Fourth 2013-02-13 19:38:39.375 App[1383:c07] Fourth: 3 // fifth tap,on Fifth 2013-02-13 19:38:40.167 App[1383:c07] Fifth: 4 // so on 2013-02-13 19:38:41.751 App[1383:c07] Sixth: 5 ------------------------------------- SECOND TAP ON SIXTH HERE 2013-02-13 19:38:42.654 App[1383:c07] Fifth: 4 2013-02-13 19:38:43.318 App[1383:c07] Fourth: 3 2013-02-13 19:38:44.495 App[1383:c07] Third: 2 2013-02-13 19:38:45.071 App[1383:c07] Second: 1
以上是大佬教程为你收集整理的ios – 奇怪的UICollectionView选择行为全部内容,希望文章能够帮你解决ios – 奇怪的UICollectionView选择行为所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。