uitouch用法
来源:互联网 发布:tvp是什么软件 编辑:程序博客网 时间:2024/05/22 18:24
http://blog.sina.com.cn/s/blog_661314940100og3b.html
前面写了几次提到UITouch,也提到了UITouch的三个代理方法
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event;
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event;
这里还有几个代理方法
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event;//触摸取消事件
- (void)remoteControlReceivedWithEvent:(UIEvent *)event;//注册接受触摸事件的Control
下面写了一个简单的DEMO,触摸时,移动图片
- (void)loadView {
[super loadView];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
UIImageView *image = [[UIImageView alloc] initWithFrame:CGRectMake(20.0, 50.0, 45.0, 45.0)];
image.image = [UIImage imageNamed:@"1.png"];
image.tag = 100;
[self.view addSubview:image];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
UIImageView *view1 = (UIImageView*)[self.view viewWithTag:100];
CGPoint point = [touch locationInView:self.view];
CGRect frame = view1.frame;
frame.origin = point;
view1.frame = frame;
}
- uitouch用法
- UITouch的用法
- 触摸事件UITouch的用法
- 触摸事件UITouch的用法
- 触摸事件UITouch的用法
- 触摸事件UITouch的用法
- 触摸事件UITouch的用法
- UITouch
- UITouch
- UITouch
- UITouch
- UITouch
- UITouch
- UITouch
- UITouch
- UITouch
- UITouch
- UITouch
- cocos2d-x 资源整理贴
- Sed 的使用方法
- 你的CSS before和after不起效果 看看是不是我这种情况
- 函数strcpy和函数memcpy
- IB中如何自定义TableViewCell
- uitouch用法
- ABAP的MD5
- Access注入点高级运用总结
- 研磨设计模式之简单工厂模式-2
- 让span有固定宽度 兼容IE和firefox
- Application .SetCompatibleTextRenderingDefault 方法
- C++调用exe文件
- UVa 10921 - Find the Telephone
- Unity3d 管理多个摄像机