码:
- (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是空的所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)