【问题标题】:Collection View to Detail View集合视图到详细视图
【发布时间】:2014-04-08 20:46:54
【问题描述】:

我有一个包含 10 个图像的集合视图,按下每个图像时都应该转到显示该图像的详细视图,但是我需要帮助将图像从集合视图推送到详细视图。我拥有的所有图像的代码是这样的:

    -(MyCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {

    MyCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"CELL" forIndexPath:indexPath];

    PFObject *imageObject = [imageFilesArray objectAtIndex:indexPath.row];
    __block UIImage *MyPicture = [[UIImage alloc]init];
    PFFile *imageFile = [imageObject objectForKey:@"test"];


    [imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error) {
        if (!error) {
            MyPicture = [UIImage imageWithData:data];
            cell.CollectionImg.image = [UIImage imageWithData:data];

        }
    }];

    return cell;
}

这是选择图像的代码:

    - (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{

    TableDetailViewController  *objDetail = [[TableDetailViewController alloc] initWithNibName:@"TableDetailViewController" bundle:nil];
    [self addChildViewController:objDetail];
    objDetail.view.frame = CGRectMake(0.0f, 0.0f, 320.0f, 568.0f);
    [self.view addSubview:objDetail.view];
}

而且我什至不确定在视图中写入的内容确实加载到 TableDetailViewController 上。如果有人可以帮助我,我将不胜感激。

【问题讨论】:

    标签: ios uiviewcontroller uicollectionview detailview


    【解决方案1】:

    您不太可能想要 addChildViewController: 和 addSubview:。更常见的模式是使用 presentViewController:如果你想要一个模态详细视图,或者有一个 navigationController 并使用 [[self navigationController] pushViewController:...] 如果你想要一个后退按钮等等。

    【讨论】:

      猜你喜欢
      • 2013-08-10
      • 1970-01-01
      • 2014-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多