我正在尝试开发一个分析应用程序来确定你是否“聪明”这涉及到给自己拍照并将点拖到你的脸上,鼻子、嘴巴和眼睛所在的位置。但是,我尝试过的代码不起作用:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:self.view];
if ([touch view] == eye1)
{
eye1.center = location;
}
else if ([touch view] == eye2)
{
eye2.center = location;
}
else if ([touch view] == nose)
{
nose.center = location;
}
else if ([touch view] == chin)
{
chin.center = location;
}
else if ([touch view] == lip1)
{
lip1.center = location;
}
else if ([touch view] ==lip2)
{
lip2.center = location;
}
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesBegan:touches withEvent:event];
}
发生了什么,因为当我只有一个图像时,它可以工作,但对我没有帮助。我该怎么做才能让它发挥作用?这些点从屏幕底部的“工具栏”开始,然后用户将它们拖到脸上。我有点希望完成的结果看起来像: