shrimp-hamburger 2013-07-18 07:02 采纳率: 0%
浏览 2131
已采纳

点击关闭按钮隐藏subView

iPhone应用中,添加subView到窗口,还要实现一个功能,在点击关闭按钮是,应该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];  

关闭按钮:

  -(void)closeButtonAction{
  NSLog(@"CLicked on this button");
  [subView removeFromSuperview] ; 
  self.tableView.userInteractionEnabled=TRUE;

}

  • 写回答

2条回答

  • Kill_it 2013-07-18 08:40
    关注

    使用removefromsuperview删除subView,如果只是想隐藏 subView.hidden = YES;,在按钮动作内执行。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制