如何隐藏在iphone应用程序中单击按钮时删除子视图

use*_*329 1 iphone window subview ios

我有iphone应用程序,其中我将subView添加到窗口它工作正常但我希望当我按下关闭按钮它应该隐藏subView这里是我做的创建子视图的代码

 UIView*subView=[[UIView alloc]initWithFrame:CGRectMake(0,0, 1024,768)];
 subView.backgroundColor=[UIColor colorWithPatternImage:[UIImage imageNamed:@"bgPopupback.png"]];
 UIWindow* window = [UIApplication sharedApplication].keyWindow;
 if (!window) 
    window = [[UIApplication sharedApplication].windows objectAtIndex:0];
 [[[window subviews] objectAtIndex:0] addSubview:subView];  
Run Code Online (Sandbox Code Playgroud)

关闭按钮操作

   -(void)closeButtonAction{



   NSLog(@"CLicked on this button");

  [subView removeFromSuperview] ; 

  self.tableView.userInteractionEnabled=TRUE;

  }
Run Code Online (Sandbox Code Playgroud)

Ven*_*enk 9

您可以删除您的subView使用removeFromSuperview,如果您只想隐藏您的子视图,则意味着subView.hidden = YES;在您的按钮操作中使用