本文主要是介绍iOS 关于UICollectionView选中状态,当使用reloadData方法时出现数据的问题?,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
直接贴代码:
#import "ViewController.h"@interface MyCollectionViewCell : UICollectionViewCell
/* *< 是否被选中 >* */
@property (assign,nonatomic,getter=isBeSelected) BOOL beSelected;@end
/* *< @implementation Cell >* */
@implementation MyCollectionViewCell
@synthesize beSelected = _beSelected;
- (BOOL)isBeSelected
{return _beSelected;
}
- (void)setBeSelected:(BOOL)beSelected
{_beSelected = beSelected;self.backgroundColor = _beSelected?[UIColor redColor]:[UIColor whiteColor];
}
@end
#pragma mark - ****< viewController >****
@interface ViewController ()@property (strong,nonatomic) UICollectionView *collectionView;
@property (strong,nonatomic) NSMutableArray *dataSouceArray;@end
/* *< @implementation viewController >* */
@implementation ViewController- (void)viewDidLoad {[super viewDidLoad];UICollectionV
这篇关于iOS 关于UICollectionView选中状态,当使用reloadData方法时出现数据的问题?的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!