我有一個UICollectionView控制器嵌入導航控制器內。 collectionView列出了項目,每個單元都應該延伸到ProjectDetail屏幕。iOS:故事板CollectionView不會被觸發
我根本無法得到繼續觸發。如果我簡單地在導航欄上放置一個按鈕並將細節連接到細節,它就可以工作。但從我的CollectionView單元觸發不。
這裏是故事板的樣子:我做http://cl.ly/RfcM有從CollectionViewCell掛在ProjectDetailViewController
一個賽格瑞這裏是我的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;
}
我猜問題在於我如何將單元連接到CollectionView。
任何幫助將不勝感激!
那麼有人能告訴我發生了什麼變化嗎?因爲在這裏http://www.appcoda.com/ios-collection-view-tutorial/我們可以清楚地看到連接是在「Storyboard」中進行的,並且它可以工作。 – Pahnev
此答案已過時。當然,你可以直接在Storyboard中創建segues。 –