0

我有一个带有 a 的View( CupsViewController),Label当它被点击时,TableView( AddressTableController) 从屏幕底部滑动并停留在下半部分。在TableView,Ok Button按下时,我想改变值Label并用动画移除TableView(即滑动到底部)。

这是我的代码:

CupsViewController

点击时调用的方法Label

- (IBAction)showPop:(id)sender
{
    addressTableController = [[AddressTableController alloc]initWithStyle:UITableViewStyleGrouped];
    [addressTableController setDelegate:self];
    [[self view] addSubview:[addressTableController myTableView]];
    [UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
        [[addressTableController myTableView] setFrame:CGRectMake(0, kScreenHeight * 0.5, kScreenWidth, kScreenHeight * 0.5)];
    } completion:nil];
}

按下AddressTableController时调用的方法Button

- (void)addressTableController:(AddressTableController *)viewController didChooseValue:(int)value {
    direccionLabel.text = [[[[myAppDelegate usuarioActual] cups] objectAtIndex:value] direccion];
    [addressTableController.view removeFromSuperview];
}

图片

在此处输入图像描述

如您所见,我已经尝试过,removeFromSuperview但它什么也没做。我怎样才能滑到TableView底部?

4

1 回答 1

1

您的属性似乎myTableView返回了不同的视图,而不是属性中引用的视图view。因此,您基本上将前者添加为子视图([[self view] addSubview:[addressTableController myTableView]];),但尝试删除后者([addressTableController.view removeFromSuperview];)。

做就是了

[[addressTableController myTableView] removeFromSuperview];

代替

[addressTableController.view removeFromSuperview];

干得好。队友的欢呼声!:)


PS如果你想动画视图,你可以这样做

[UIView animateWithDuration:1.0 delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
    // animation code...
} completion:^(BOOL finished) {
    [[addressTableController myTableView] removeFromSuperview];
}];
于 2013-08-07T08:55:36.297 回答