1

アプリ内で単一の UITableView を使用しています。行の選択などに応じて、UITableView のデリゲートとデータソースを変更します。

ユーザーの動きに合わせてトランジションをアニメーション化するには、現在の UITableView の画像を取得し、UITableView の上に配置された UIImageView に画像を配置し、UITableView で Data を再ロードしてから、アニメーション化されたトランジション内の UIImageView を削除します。

次のようにコードします。

-(void)showImageEditPageWithImageId:(NSString*)imageId
{
    UITableView* tableview = (UITableView*)[self.view viewWithTag:VIEWTAG_P1_MAINTABLEVIEW];

    UIImage* image = [HPSImageHelper imageWithView:tableview];
    UIImageView* imageView = [[UIImageView alloc] initWithFrame:tableview.frame];
    imageView.tag = 336611;
    imageView.layer.borderWidth=1;
    imageView.layer.borderColor = [UIColor blueColor].CGColor;
    [imageView setImage:image];

    _tableViewController = [[HPSImageEditTableViewController alloc] initWithImageId:imageId];
    ((HPSImageEditTableViewController*)_tableViewController).callingController = self;    
    tableview.dataSource = _tableViewController;
    tableview.delegate = _tableViewController;

    [tableview reloadData];

    [tableview.superview addSubview:imageView];

    [NSTimer scheduledTimerWithTimeInterval:0.1
                                     target:self
                                   selector:@selector(removeCoveringImage)
                                   userInfo:nil
                                    repeats:NO];

}

-(void)removeCoveringImage
{
    UIView* imageView = [self.view viewWithTag:336611];

    [UIView transitionWithView:imageView
                      duration:0.9
                       options:UIViewAnimationOptionTransitionCurlUp
                    animations:^{
                        //Nothing here

                    }
                    completion:^(BOOL finished){

                        [imageView removeFromSuperview];
                    }
     ];

}

問題は、遷移が完了すると UITableView が視覚的にのみ更新されるため、新しいビューが突然表示されることです。

UITableView は、実際には表示されていないことを「認識」しているため、更新されていないように思えます。

それが起こっているのですか?もしそうなら、UIImageViewで覆われているにもかかわらず、UITableViewを再描画するにはどうすればよいですか?

ありがとう。

4

1 に答える 1

0

データをロードした後、テーブル ビューで setNeedsDisplay を呼び出してみてください。それでも解決しない場合は、アニメーションに UIViewAnimationOptionLayoutSubviews オプションを追加してみてください。これらのいずれも役に立たない場合は、アニメーションの前に tableView を強制的に再描画するのに十分なだけ (0.99 または 0.98 または 0.90) だけ imageView のアルファを下げてみてください。これが役に立ったことを願っています

于 2012-09-25T14:49:39.300 に答える