Hi, I'm new to posting on this forum but can't tell you how many times reading it has helped me out. Currently I'm working on a game for the iPhone it has a grid of UIImageViews that are contained within a subview of my gameboardViewController. I build the grid on ViewDidLoad. Ok so far. Now I am using touchesBegan to figure out which one of the UIImageViews was touched, which kind-of works. I say kind-of because CGRectContainsPoint seems to give a false result, meaning the top row of this grid is thought by that function to be outside of my subview rect.
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *) event
{
UITouch *touch = [touches anyObject];
CGPoint currentLocation = [[touches anyObject] locationInView:self.gridView];
CGRect gridRect = self.gridView.frame;
// Since I have an overlay I want to ignore touches when this subview is visible.
if(self.readyScreen.hidden)
{
/* restrict the touches to only the subview gridView so any stray touches should be ignored.*/
if(CGRectContainsPoint(gridRect,currentLocation) )
{
UIImageView *theTile = (UIImageView *)touch.view;
[self gridItemTouched:theTile];
}
}
}
For some reason it isn't accurate enough to see that the top row of 50 x 50 UIImageViews are within the subview.
Any suggestions?