【发布时间】:2015-07-21 14:45:19
【问题描述】:
我有问题。我有一个 ViewController1 包含一个 tableView.that tableView 创建一个自定义 tableViewCell
-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
TableCategoryCell *cell = (TableCategoryCell *)[tableView dequeueReusableCellWithIdentifier:CategoryCellIndentifier];
}
在自定义单元格 TableCategoryCell.m 中包含一个 collectionView。
-(UICollectionViewCell*)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
UICollectionViewCell *cell_collection = [collectionView dequeueReusableCellWithReuseIdentifier:COLLECTION_CELL_IDENTIFIER forIndexPath:indexPath];
}
现在我希望用户单击 didSelectItemAtIndexPath 方法中的 collectionView 项打开新的 ViewController2 并将数据传递给 ViewController 2?
-(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UINavigationController *navigationController =[storyboard instantiateViewControllerWithIdentifier:@"Navigation"];
ViewController2 *watchController = [storyboard instantiateViewControllerWithIdentifier:WATCH_IDENTIFIER];
[navigationController pushViewController:watchController animated:YES];
}
我可以从情节提要的集合项中推送 ViewController2,但我不知道在编程中? 我该怎么办?
【问题讨论】:
-
所以,如果您在集合视图中选择单元格,它应该推送到第二个视图控制器。你是这个意思吗?
-
是的..我不知道如何推送到第二个 ViewController
标签: ios objective-c uitableview