关闭subView

时间:2012-04-22 17:05:13

标签: objective-c xcode

我在FirstViewController中有这样的代码

{
SecondViewController *objComing=[[SecondViewController alloc] init];
[self.view addSubview:objComing.view];

objComing.view.backgroundColor=[UIColor blueColor];

objComing.view.frame=CGRectMake(0,420, 320, 0);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];

[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
objComing.view.frame=CGRectMake(0,0, 320, 420);

[UIView commitAnimations];
}

SecoundViewController包含关闭/关闭的按钮。怎么看IBAction连接到按钮(包括在SecoundViewController中)来解散/删除和隐藏这个覆盖层?

2 个答案:

答案 0 :(得分:1)

在“关闭/关闭”按钮方法中,添加以下行以删除secondviewcontroller子视图:

[self.view removeFromSuperview];

答案 1 :(得分:0)

[self.view removeFromSuperview];