【发布时间】:2011-11-17 06:57:08
【问题描述】:
我正在制作一个应用程序,我在 IBAction 上使用 addSubview: 将子视图添加到视图中。同样,当再次触摸带有IBAction 的按钮时,应在添加到IBAction 的子视图上调用removeFromSuperview:
伪代码
-(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];
}
}
【问题讨论】:
标签: ios cocoa-touch uiview uikit