UIView添加点击事件
2016-08-24 18:24
197 查看
使用 UITapGestureRecognizer ,创建一个 UITapGestureRecognizer 将它添加到view上即可
事例代码
UIView *tapView=[[UIView alloc]initWithFrame:SCREEN_FRAME];
UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
[tapView addGestureRecognizer:tapGesturRecognizer];
-(void)tapAction:(id)tap
{
NSLog(@"点击了tapView");
}
事例代码
UIView *tapView=[[UIView alloc]initWithFrame:SCREEN_FRAME];
UITapGestureRecognizer *tapGesturRecognizer=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tapAction:)];
[tapView addGestureRecognizer:tapGesturRecognizer];
-(void)tapAction:(id)tap
{
NSLog(@"点击了tapView");
}
相关文章推荐
- 在UIView中添加点击事件
- iOS 在添加了UITapGestureRecognizer的UIView上响应按钮的点击事件
- iOS开发封装带有Button的UIView控件,使用target-action模式给button添加点击事件
- 为UIView添加点击事件
- 在UIView中添加点击事件
- iOS-给UIView添加点击事件
- IOS开发之功能模块--给任意的UIView添加点击事件
- 为UIView添加点击事件
- 封装-给继承自UIView的控件添加点击事件
- iOS 为移动中的UIView(UIButton )添加点击事件
- ios UIView控件设置动画后添加点击事件不起作用
- UIView添加手势 然后UITableView 添加进这个View 导致UITableView 的单元格点击事件无效
- 在UIView中添加点击事件oc及swift
- UIView 添加点击事件
- 给uiview添加点击事件
- iOS 给UIView、UIImageView、UILabel添加点击事件
- iOS UIView 添加点击事件
- UIView添加手势 然后UITableView 添加进这个View 导致UITableView 的单元格点击事件无效
- Swift 2.1 为 UIView 添加点击事件和点击效果
- iOS开发封装带有Button的UIView控件,使用代理给button添加点击事件