在UITableViewCell类中推送详细视图

时间:2012-06-19 01:47:04

标签: ios uiview

我的类继承自UITableViewCell,我已经制作了一些自定义过渡来在选择图像时推送新的详细信息视图。

[UIView transitionWithView:self.masterView duration:0.5 options:UIViewAnimationOptionShowHideTransitionViews
                    animations:^ { 
                        [self.masterView addSubview:self.detailImage];
                    }
                    completion:nil];   

我的代码工作正常,detailImage子视图显示有转换,但这种转换不是我想要的。我想要执行的是从底部到顶部的简单过渡。 UIViewAnimation列表不包含此类动画。

有没有办法在不将我的类继承更改为UINavigationController的情况下使用该转换?

1 个答案:

答案 0 :(得分:1)

如果我理解你的话,下面的代码可能就是你想要的。

CGRect detailImageFrameOri = self.detailImage.frame; 
CGRect detailImageFrame = detailImageFrameOri;
detailImageFrame.origin.y += self.detailImage.frame.size.height;
self.detailImage.frame = detailImageFrame;

[self.masterView addSubview:self.detailImage];

[UIView animateWithDuration:0.5 animations:^{
    self.detailImage.frame = detailImageFrameOri;
}];

希望这可以帮到你。

编辑: 从上到下,

CGRect detailImageFrame = self.detailImage.frame;
detailImageFrame.origin.y += self.detailImage.frame.size.height;

[self.masterView addSubview:self.detailImage];

[UIView animateWithDuration:0.5 
                 animations:^{
                     self.detailImage.frame = detailImageFrame;
                 } 
                 completion:^(BOOL finished) {
                     [self.detailImage removeFromSuperview];      
                 }];