Saya membuat aplikasi tempat saya menambahkan subview ke tampilan menggunakan addSubview:di IBAction. Dengan cara yang sama, ketika tombol dengan yang IBActiondisentuh lagi harus memanggil removeFromSuperviewsubview yang ditambahkan itu IBAction:
KODE 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];
}
}