【发布时间】:2014-12-02 11:14:09
【问题描述】:
所以,我在使用 touchesBegan 和 touchesMoved 移动一些图像时遇到问题,这里是我的 p1 UIImageView 代码
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView: touch.view];
NSLog(@"incepe");
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
if (touch.view == self.p1) {
CGPoint location = [touch locationInView: self.view];
self.p1.center = location;
NSLog(@"nmk");
}
}
我添加图片的方式是这样的
-(void)img{
if (!self.p1) {
self.p1 =[[UIImageView alloc] initWithFrame:CGRectMake(14,20,70,50)];
}
[self.view addSubview:self.p1];
}
当我按下 p1 UIImageview 时,不会触发 touchesmoved 事件
【问题讨论】:
标签: ios objective-c xcode uiimageview