ios – UICollectionview是空的

ios – UICollectionview是空的,第1张

概述嗨我创建了一个UIViewController,我添加了一个带CustomCell的UICollectionView.然后,我为单元格创建了一个uicollectionviewcell类.最后在storybord本身设置委托和数据源.但它显示空页.如下图所示 码: - (void)viewDidLoad{ [super viewDidLoad]; self.collectionv 嗨我创建了一个UIVIEwController,我添加了一个带CustomCell的UICollectionVIEw.然后,我为单元格创建了一个uicollectionvIEwcell类.最后在storybord本身设置委托和数据源.但它显示空页.如下图所示

码:

- (voID)vIEwDIDLoad{    [super vIEwDIDLoad];    self.collectionvIEw = _collectionvIEw;    self.collectionvIEw.dataSource = self;    self.collectionvIEw.delegate = self;    speakersImages=[[NSMutableArray alloc]init];    // Do any additional setup after loading the vIEw,typically from a nib.    imageLabels=[[NSMutableArray alloc]initWithObjects:@"RB Forum 2013",@"Agenda",@"Speakers",@"Contact",@"Map",@"Websites",@"@Responsible Biz",@"Partners",@"Sustainability",nil];    imagePaths=[[NSMutableArray alloc]initWithObjects:[UIImage imagenamed:@"RBform.png"],[UIImage imagenamed:@"agenda.png"],[UIImage imagenamed:@"speakers.png"],[UIImage imagenamed:@"contact.png"],[UIImage imagenamed:@"map.png"],[UIImage imagenamed:@"website.png"],[UIImage imagenamed:@"twitter.png"],[UIImage imagenamed:@"partners.png"],[UIImage imagenamed:@"sustainability.png"],nil];    [self.collectionvIEw registerClass:[NewCell class] forCellWithReuseIDentifIEr:@"Cell"];}- (NSInteger)numberOfSectionsInCollectionVIEw:(UICollectionVIEw *)collectionVIEw{    return 1;}- (NSInteger)collectionVIEw:(UICollectionVIEw *)collectionVIEw     numberOfItemsInSection:(NSInteger)section{    return [imageLabels count];}//THE BELOW DELEGATE METHOD DOES NOT GET CALLED!- (voID)dIDReceiveMemoryWarning{    [super dIDReceiveMemoryWarning];    // dispose of any resources that can be recreated.}- (UICollectionVIEwCell *)collectionVIEw:(UICollectionVIEw *)collectionVIEw cellForItemAtIndexPath:(NSIndexPath *)indexPath{    // we're going to use a custom UICollectionVIEwCell,which will hold an image and its label    //    static Nsstring *CellIDentifIEr = @"Cell";    NewCell *cell = [collectionVIEw dequeueReusableCellWithReuseIDentifIEr:CellIDentifIEr forIndexPath:indexPath];    // make the cell's Title the actual NSIndexPath value    cell.labels.text = [Nsstring stringWithFormat:@"%@",[imageLabels objectAtIndex:indexPath.row]];    // load the image for this cell    NSLog(@"%@",imageLabels);    //Nsstring *imagetoLoad = [Nsstring stringWithFormat:@"%d.JPG",indexPath.row];    //    cell.image.image = [UIImage imagenamed:imagetoLoad];    cell.images.image = [imagePaths objectAtIndex:indexPath.row];    return cell;}
解决方法 解决方案已删除
[self.collectionvIEw registerClass:[NewCell class] forCellWithReuseIDentifIEr:@“Cell”];

在storybord我们不需要这个

总结

以上是内存溢出为你收集整理的ios – UICollectionview是空的全部内容,希望文章能够帮你解决ios – UICollectionview是空的所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1005014.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存