【发布时间】:2014-08-07 06:11:06
【问题描述】:
我试图在触摸屏幕时在屏幕上创建一个点,然后能够移动该点,然后结束触摸,这将显示一个警报视图。对于第一次触摸和移动,到目前为止我有这个代码......
{
UIImageView *dot =[[UIImageView alloc] initWithFrame:CGRectMake(359,487,50,50)];
dot.image=[UIImage imageNamed:@"hockey-puck-stress-toy-superextralarge-175648.png"];
[self.view addSubview:dot];
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
dot.center = location;
}
-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesBegan:touches withEvent:event];
}
问题是这会在移动时创建一个新对象,而不是在我第一次触摸它时。我明白为什么会这样,但我不知道有什么方法可以解决它。有人可以帮忙吗?谢谢!
【问题讨论】:
标签: ios touchesbegan touchesmoved