I've implemented the GMGridview in my program. I found this code on github. Click here My program is a grid view of my business' products. Each product is a custom UIButton inside a scroll view. Im looking for ways to get the location of each button (which is the product) but every time i click different buttons it still gives me the same location. I don't understand why this is. It supposed to detect what button I am clicking.
I used this code to get the location:
CGPoint myPoint = CGPointMake (senderButton.frame.origin.x, senderButton.frame.origin.y);
CGPoint angelPoint= [senderButton.superview convertPoint:myPoint toView:self.view];
I've also researched some solutions to this problem but it didn't work for me, in this case.
Thank you.
Usually, it is not required to do calculations on the coordinates of your tap event to know which button you have tapped. Indeed, the
senderButtonargument is just telling you exactly that. You might think of associating atagvalue to each button when you build your grid (e.g, a sequence number), and then use that tag in your action handler to identify the button on a more "logical" level:As to your original question, your code seems fine. The only potential issue I see is with
self.view. Which view does it identify? And have you tried passingnilso that you get coordinates in theUIWindowspace?