ios addsubview可以取消吗
答案:1 悬赏:80 手机版
解决时间 2021-01-28 09:17
- 提问者网友:溺爱和你
- 2021-01-28 01:52
ios addsubview可以取消吗
最佳答案
- 五星知识达人网友:往事埋风中
- 2021-01-28 03:01
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;
}
解决方法 :
使用removefromsuperview删除subView,如果只是想隐藏 subView.hidden = YES;,在按钮动作内执行。
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;
}
解决方法 :
使用removefromsuperview删除subView,如果只是想隐藏 subView.hidden = YES;,在按钮动作内执行。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯