Tôi đang tạo một ứng dụng trong đó tôi thêm một chế độ xem phụ addSubview:vào một chế độ xem bằng cách sử dụng một IBAction. Theo cách tương tự, khi nút có nút đó IBActionđược chạm lại sẽ gọi removeFromSuperviewtrên lượt xem phụ đó được thêm vào đó IBAction:
MÃ 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];
}
}