我将Xcode更新为9并使用iOS 11作为Base SDK。不知何故,当我这样做时,事情发生了变化。从那时起,我的应用程序中的集合视图没有显示。 NSLog永远不会在控制台中显示部分中的项目数,当我为cellForItem输入NSLog时,NSLog永远不会在控制台中触发任何内容。在XIB中,所有内容都正确连接,同样,这适用于AppStore中已存在的应用程序,除了下载新的Xcode之外,我在代码中没有更改任何内容。世界上到底发生了什么?这是代码:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
[self.tableView deselectRowAtIndexPath:selectedIndexPath animated:YES];
}
- (void)viewDidLoad
{
[super viewDidLoad];
arryData = [[NSArray alloc] initWithObjects:@"AIMCON", @"Devotional Songs", @"Saved Devotionals", @"AIM Series 2017", @"Resources", @"Podcasts", @"Website", @"Links", nil];
CALayer * l = [viewofimage layer];
[l setMasksToBounds:YES];
[l setCornerRadius:11];
[l setBorderWidth:2.0];
[l setBorderColor:[[UIColor blackColor] CGColor]];
tableView.contentInset = UIEdgeInsetsMake(0, 0, 0, 0);
[self.collectionView registerClass:[CVCell class] forCellWithReuseIdentifier:@"cvCell"];
self.collectionView.backgroundColor = [UIColor whiteColor];
self.collectionView.delegate = self;
// Do any additional setup after loading the view.
}
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
NSLog(@"1");
}
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [arryData count];
NSLog(@"2");
}
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"Selected");
if (indexPath.row == 1) {
DevoSongs *dvController = [[DevoSongs alloc] initWithNibName:@"DevoSongs" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController animated:YES];
[dvController release];
}
if (indexPath.row == 2) {
ListOfDevos *dvController7 = [[ListOfDevos alloc] initWithNibName:@"ListOfDevos" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController7 animated:YES];
[dvController7 release];
}
if (indexPath.row == 4) {
AIMProject *dvController7 = [[AIMProject alloc] initWithNibName:@"AIMProject" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController7 animated:YES];
[dvController7 release];
}
if (indexPath.row == 5) {
Podcasts *dvController2 = [[Podcasts alloc] initWithNibName:@"Podcasts" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController2 animated:YES];
[dvController2 release];
}
if (indexPath.row == 6) {
FamilyMinistry *dvController5 = [[FamilyMinistry alloc] initWithNibName:@"FamilyMinistry" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController5 animated:YES];
[dvController5 release];
}
if (indexPath.row == 7) {
LinksViewController *dvController6 = [[LinksViewController alloc] initWithNibName:@"LinksViewController" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController6 animated:YES];
[dvController6 release];
}
if (indexPath.row == 0) {
NSLog(@"TABLE");
SECTable *dvController7 = [[SECTable alloc] initWithNibName:@"SECTable" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController7 animated:YES];
[dvController7 release];
}
if (indexPath.row == 3) {
NSLog(@"AIM Series");
AIMSeries *dvController9 = [[AIMSeries alloc] initWithNibName:@"AIMSeries" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:dvController9 animated:YES];
[dvController9 release];
}
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *cellIdentifier = @"cvCell";
CVCell *cell = (CVCell *)[collectionView dequeueReusableCellWithReuseIdentifier:cellIdentifier forIndexPath:indexPath];
NSString *thearticleImage = [[arryData objectAtIndex:indexPath.row] stringByAppendingString:@".png"];
[cell.theimage setImage:[UIImage imageNamed:thearticleImage]];
//titleLabel2.text = entry.articleTitle;
CALayer * l = [cell.theimage layer];
[l setMasksToBounds:YES];
[l setCornerRadius:11];
[l setBorderWidth:2.0];
[cell.labels setText:[arryData objectAtIndex:indexPath.row]];
NSLog(@"%@", cell.labels.text);
return cell;
}
@end
答案 0 :(得分:0)
将集合视图的isPrefetchingEnabled属性设置为false。