
集合可重用视图标识符设置为“ItemCell”.自定义视图单元格设置为“CustomVIEwCell”类. CollectionVIEw的dataSource和delegate已设置为FirstVIEwController.
那是代码:
FirstVIEwcontroller:#import <UIKit/UIKit.h>#import "CustomVIEwCell.h"@interface FirstVIEwController : UIVIEwController<UICollectionVIEwDataSource,UICollectionVIEwDelegate>@property (weak,nonatomic) IBOutlet UITextFIEld *txtFIEld;- (IBAction)slIDeRed:(ID)sender;- (IBAction)slIDeGreen:(ID)sender;- (IBAction)slIDeBlue:(ID)sender;- (IBAction)btnAdd:(ID)sender;@end
.m文件:
#import "FirstVIEwController.h"@interface FirstVIEwController ()@end@implementation FirstVIEwController- (voID)vIEwDIDLoad{ [super vIEwDIDLoad]; // Do any additional setup after loading the vIEw,typically from a nib.}-(voID)vIEwDIDAppear:(BOol)animated{}- (voID)dIDReceiveMemoryWarning{ [super dIDReceiveMemoryWarning]; // dispose of any resources that can be recreated.}-(NSInteger)numberOfSectionsInCollectionVIEw:(UICollectionVIEw *)collectionVIEw{ return 10;}-(NSInteger)collectionVIEw:(UICollectionVIEw *)collectionVIEw numberOfItemsInSection:(NSInteger)section{ return 5;}-(UICollectionVIEwCell *)collectionVIEw:(UICollectionVIEw *)collectionVIEw cellForItemAtIndexPath:(NSIndexPath *)indexPath{ CustomVIEwCell *cell = [collectionVIEw dequeueReusableCellWithReuseIDentifIEr:@"ItemCell" forIndexPath:indexPath]; if (cell == nil) { cell = [[CustomVIEwCell alloc]init]; } cell.label.text = @"KitKat"; //cell.lblMain.textcolor = [UIcolor whitecolor]; // cell.backgroundcolor = [UIcolor blackcolor]; return cell;}- (IBAction)slIDeRed:(ID)sender {}- (IBAction)slIDeGreen:(ID)sender {}- (IBAction)slIDeBlue:(ID)sender {}- (IBAction)btnAdd:(ID)sender {}@end CustomVIEwCell:
#import "CustomVIEwCell.h"@implementation CustomVIEwCell@synthesize label;- (ID)initWithFrame:(CGRect)frame{ self = [super initWithFrame:frame]; if (self) { // Initialization code } return self;}@end 如何强制该collectionVIEw窗口显示带有标签的customCell.然而它只是黑色的窗户.
最好的祝福
以上是内存溢出为你收集整理的ios – CollectionView窗口保持黑色全部内容,希望文章能够帮你解决ios – CollectionView窗口保持黑色所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)