2012-04-22 59 views
0

我在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中)來解除/移除並隱藏這個覆蓋層?

回答

1

在關閉/解僱按鈕方法添加以下行以除去secondviewcontroller子視圖:

[self.view removeFromSuperview]; 
+0

如果我將它添加到SecoundViewController.m中的方法並給出,它會崩潰。 「(lldb)」 – 2012-04-22 18:01:06

+0

很難通過您在這裏提供的信息來猜測發生了什麼。請提供更好的細節。 懷疑這是問題,但在上面的代碼中,我沒有看到任何[objComing版本],因爲你alloc-init它。 – HM1 2012-04-23 05:41:07