检查子视图是否在视图中
我在做一个应用程序,我一个子视图添加到使用视图addSubview:上IBAction。同样,当IBAction再次触摸带有该按钮的按钮时,应调用removeFromSuperview添加在该子视图上的该子视图IBAction: 伪代码 -(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]; } }