Mam kontroler UICollectionView osadzony w kontrolerze nawigacyjnym. KolekcjaView wyświetla projekty, a każda komórka ma przejść do ekranu ProjectDetail.iOS: Komornik CollectionView nie jest wyzwalany
Po prostu nie mogę uruchomić przełącznika. Jeśli po prostu upuszczę przycisk na pasku nawigacji i podłączę się do szczegółów, to działa. Ale wyzwalanie z mojej komórki CollectionView nie.
Oto co storyboard wygląda następująco: http://cl.ly/RfcM Mam segue związał się z CollectionViewCell do ProjectDetailViewController
Oto odpowiedni kod w moim 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;
}
Zgaduję problem polega na tym, że podłączam komórki do CollectionView.
Każda pomoc będzie bardzo ceniona!
Czy ktoś może mi powiedzieć, co się zmieniło? Ponieważ tutaj http://www.appcoda.com/ios-collection-view-tutorial/ widać wyraźnie, że połączenie jest wykonane w 'Storyboard' i działa. – Pahnev
Ta odpowiedź jest nieaktualna. Zdecydowanie możesz tworzyć segues bezpośrednio w Storyboard. –