1

我正在使用以下代码从表格视图中缩放/放大图像。我希望它放大到全屏。当前的问题是,当它放大时,它仅在表格单元格内放大(因此部分隐藏在下一个表格单元格下方)而不是完整视图。

    -(void)zoomPhotoMethod :(id) sender
{
    UITapGestureRecognizer *gesture = (UITapGestureRecognizer *) sender;
    NSLog(@"Tag = %d", gesture.view.tag);

    userSubmittedImageView = (UIImageView *)gesture.view;

    if (!isFullScreen) {
        [UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
            //save previous frame
            prevFrame = userSubmittedImageView.frame;

            UIView *popupImageViewForTableCell = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 320, 500)];

            [userSubmittedImageView setFrame:[popupImageViewForTableCell bounds]];


        }completion:^(BOOL finished){
            isFullScreen = TRUE;
        }];
        return;
    }
    else{
        [UIView animateWithDuration:0.5 delay:0 options:0 animations:^{
            [userSubmittedImageView setFrame:prevFrame];
        }completion:^(BOOL finished){
            isFullScreen = FALSE;;
        }];
        return;
    }


}

更新代码:

   -(void)zoomPhotoMethod :(id) sender
{
    UITapGestureRecognizer *gesture = (UITapGestureRecognizer *) sender;
    NSLog(@"Tag = %d", gesture.view.tag);

    userSubmittedImageView = (UIImageView *)gesture.view;

    if (!isFullScreen) {
        [UIView animateWithDuration:0.3 delay:0 options:0 animations:^{
            //save previous frame
            prevFrame = userSubmittedImageView.frame;


            newView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)];

            [self.view addSubview:newView];

            UIView *popupImageViewForTableCell = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 320, 500)];

            [userSubmittedImageView setFrame:[popupImageViewForTableCell bounds]];

            [newView addSubview:userSubmittedImageView];

            [userSubmittedImageView setFrame:[newView bounds]];

        }completion:^(BOOL finished){
            isFullScreen = TRUE;
        }];
        return;
    }
    else{
        [UIView animateWithDuration:0.3 delay:0 options:0 animations:^{

            [userSubmittedImageView setFrame:prevFrame];


            [newView setFrame:prevFrame];

        }completion:^(BOOL finished){
            isFullScreen = FALSE;;
        }];
        return;
    }


}
4

2 回答 2

3

发生的事情是您仍然是 tableview 单元格的子视图,因此它无法在不被剪裁的情况下超出这些范围。

要做你想做的事,你必须:

  1. 在表格视图之外创建一个新的 UIImageView(将其添加为表格视图之外的子视图)。
  2. 将图像视图中的图像设置为与表格视图单元格中相同的图像。
  3. 以与 tableview 单元格图像相同的大小和位置启动它。
  4. 将其动画到您想要的位置。
  5. 当需要删除它时,将其移回原始的 tableview 单元格图像。
  6. 丢弃图像视图。
于 2013-10-25T14:27:54.450 回答
2

One way would be to use a copy of the image and place it outside the cell just above your original and animate this second image to full screen.

Another way would be to increase the tableView rowHeight and reload the section.

于 2013-10-25T14:22:54.373 回答