I have 2 Views, each View have a ViewController.
I opened the first view early in TabController.
Then (when a line 开发者_高级运维in a table is clicked) I use this to add my subview:
ENSListViewController *vc = [ENSListViewController alloc];
vc.folder_id = 1;
vc.folder_type = @"an";
[vc initWithNibName:@"ENSListViewController" bundle:nil];
[self.view addSubview:vc.view];
[vc release];
In the second view I try to remove this view again, but it ends in a EXC_BAD_ACESS:
- (IBAction)backToFolderList:(id)sender
{
[self.view removeFromSuperview];
}
Where is my mistake?
You are releasing vc by [vc release]; hence it is not getting object of superview.. you have to release it in -dealloc method
精彩评论