Ich habe einen UICollectionView-Controller in einem Navigationscontroller eingebettet. Die CollectionView listet Projekte auf und jede Zelle soll in einen ProjectDetail-Bildschirm übergehen.iOS: Storyboard CollectionView-Segment wird nicht ausgelöst
Ich kann einfach nicht das Segment auslösen. Wenn ich einfach einen Knopf auf der Navigationsleiste drücke und einen Übergang zum Detail anschließe, funktioniert es. Das Auslösen aus meiner CollectionView-Zelle funktioniert jedoch nicht. Hier
ist, was das Drehbuch wie folgt aussieht: http://cl.ly/RfcM Ich habe eine segue vom CollectionViewCell zum ProjectDetailViewController angeschlossen
Hier ist der entsprechende Code in meinem ProjectDetailViewController:
@interface ProjectCollectionViewController() {
NSArray *feedPhotos;
Projects *projects;
}
@end
@implementation ProjectCollectionViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.collectionView registerClass:[FeedViewCell class] forCellWithReuseIdentifier:@"cell"];
[self loadData];
}
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"selected %d", indexPath.row);
Project *project = [projects getProject:indexPath.row];
NSLog(@"project = %@", project);
}
- (void)loadData {
[self.projectLoader loadFeed:self.username
onSuccess:^(Projects *loadedProjects) {
NSLog(@"view did load on success : projects %@", loadedProjects);
projects = loadedProjects;
[self.collectionView reloadData];
}
onFailure:^(NSError *error) {
[self handleConnectionError:error];
}];
}
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return projects.count;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
static NSString *identifier = @"cell";
FeedViewCell *cell = (FeedViewCell *) [collectionView dequeueReusableCellWithReuseIdentifier:identifier forIndexPath:indexPath];
cell.backgroundColor = [UIColor colorWithRed:0.0 green:0.0 blue:1.0 alpha:1.0];
UIImageView *cellImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
Project *project = [projects getProject:indexPath.row];
NSString *imageUrl = [project coverPhotoUrl:200 forHeight:200];
NSLog(@"imageurl =>%@", imageUrl);
if (imageUrl) {
[cellImageView setImageWithURL:[NSURL URLWithString:imageUrl]];
}
[cell addSubview:cellImageView];
cell.imageView = cellImageView;
return cell;
}
Ich vermute, die Problem ist irgendwo in wie ich die Zellen an die CollectionView anschließen.
Jede Hilfe würde sehr geschätzt werden!
Kann mir jemand sagen, was sich geändert hat? Denn hier http://www.appcoda.com/ios-collection-view-tutorial/ können wir deutlich sehen, dass die Verbindung in 'Storyboard' hergestellt wird und es funktioniert. – Pahnev
Diese Antwort ist veraltet. Auf jeden Fall können Sie direkt im Storyboard Segmente erstellen. –