Estoy creando una aplicación donde agrego una subvista a una vista usando addSubview:
en un IBAction
. De la misma manera, cuando el botón con eso IBAction
se toca nuevamente, se debe llamar removeFromSuperview
a esa subvista agregada en eso IBAction
:
CÓDIGO PSEUDO
-(IBAction)showPopup:(id)sender
{
System_monitorAppDelegate *delegate = (System_monitorAppDelegate *)[[UIApplication sharedApplication] delegate];
UIView *rootView = delegate.window.rootViewController.view;
if([self popoverView] is not on rootView)
{
[rootView addSubview:[self popoverView]];
}
else
{
[[self popoverView] removeFromSuperview];
}
}