UICollectionView不会加载
我将我的Xcode更新为9并将iOS 11用于Base SDK。不知何故,当我这样做时,有些事情发生了变化。从那时起,我的应用程序中的收藏视图不显示。 NSLog从未在控制台中显示节中的项数,NSLog在放入NSLog for cellForItem时从不会在控制台中触发任何内容。在XIB中,所有东西都可以正确地连接起来,并且这是针对AppStore中已经存在的应用程序,我没有在代码中进行任何更改,除了下载新的Xcode。世界正在发生什么?这里是它的代码:UICollectionView不会加载
- (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
集收藏视图的isPrefetchingEnabled属性设置为false。
该属性已在xib文件中取消选择。 – user717452
我已经尝试在代码和XIB文件中更改集合视图的backgroundColor,但在屏幕上它仍然显示为黑色,所以我甚至不知道集合视图是否显示在屏幕上。 – user717452
寻找不推荐的集合视图委托方法。 –
@tomato我重新安装了Xcode 8,它并没有在那里加载集合视图,所以我必须在没有意识到的情况下改变它,但至于我无能为力。 – user717452
不是Xcode 9?出于什么原因,你是否重新安装Xcode 8? –