缩短tableView并在其下方滑动视图

时间:2011-02-12 18:41:06

标签: iphone objective-c ipad uitableview uiview

基本上单击一个单元格,我希望桌子可以设置动画(缩短它的高度)和一个“细节”视图以向上滑动占用现在可用的空间。

我正确地将tableView缩短了,但是我在第二个视图滑入时遇到了问题..

CGRect frame = self.tableview.frame; // (drilldown table)
if(frame.size.height > 600)
{
    CGRect detailFrame = StudyDetailView.view.frame; // (detailed view I want to slide up
    detailFrame.origin.y = (frame.size.height-200);
    self.tableview.autoresizingMask = UIViewAutoresizingNone;
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.3];
    StudyDetailView.view.frame = detailFrame; // <-- this does not work.
    self.tableview.frame = CGRectMake(0,0,frame.size.width,frame.size.height-200); // <-- this works.

    [UIView commitAnimations];


}

更新 我的修复:

StudyListDetailController.m

- (void)viewDidLoad {
    CGRect frame = self.view.frame;
    self.view.frame =  CGRectMake(0,900,frame.size.width,frame.size.height);
    [super viewDidLoad];
}

在我的表格行中选择...

if(frame.size.height > 600)
{

    CGRect detailFrame = StudyDetailView.view.frame;

    self.tableview.autoresizingMask = UIViewAutoresizingNone;
    detailFrame.origin.y = (frame.size.height-200);
    detailFrame.size.height = 200;
    [self.view addSubview:StudyDetailView.view];
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:.3];

    self.tableview.frame = CGRectMake(0,0,frame.size.width,frame.size.height-200);
    StudyDetailView.view.frame = detailFrame;
    [UIView commitAnimations];

}

1 个答案:

答案 0 :(得分:0)

您最初在哪里设置StudyDetailView.view.frame?看起来你只设置了Y值。 尝试做

NSLog(NSStringFromCGRect(detailFrame));

并查看控制台中显示的内容,我猜测只会设置y值,宽度和高度仅为0.