UIWindow
title: UIWindow相关知识
date: 2016-1-21 20:50
categories: IOS
tags: UIWindow
小小程序猿
我的博客:http://daycoding.com
获取屏幕window
[UIApplication sharedApplication].keyWindow]
屏幕上手势监听
问题:设计弹出层使用window来实现,对item
的背景设置了tap
事件,并设置了跳转,对window
的touch
事件进行设置,点击后window
消失,但是touch
会拦截tap
的事件,只好进行修改,对tap
设置了代理来进行区别tap
动作
代码:
- (void)dismiss{
[self setHidden:YES];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
// 点击消失
[self dismiss];
}
//如果不加手势监听会直接执行touchesBegan 是对话框消失
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch {
// Disallow recognition of tap gestures in the segmented control.
if ((touch.view ==_bg_head) && (gestureRecognizer == _headtap)) {
[self gotoEditUserInfoController];
}
if ((touch.view ==_bg_setting) && (gestureRecognizer == _settingtap)) {
[self gotoSettingController];
}
return YES;
}