我正在開發一個應用程序。在這我使用一個UIImageView,我正在使用下面的代碼每0.5秒更改UIImageView的位置。如何找出觸摸屏的位置
[NSTimer scheduledTimerWithTimeInterval:0.5
target: self
selector:@selector(moveImage)
userInfo: nil repeats:YES];
-(void) moveImage
{
//[image1 setCenter: CGPointMake(634, 126)];
CGFloat x = (CGFloat) (arc4random() % (int) self.view.bounds.size.width);
CGFloat y = (CGFloat) (arc4random() % (int) self.view.bounds.size.height);
CGPoint squarePostion = CGPointMake(x, y);
img.center=squarePostion;
}
現在我可以觸摸屏幕。我需要了解的是我的觸摸位置和圖像視圖位置都正確與否。
每次去其他block.I寫你的代碼touchEnded方法。 –