How to retrieve the location of a control on the view?

Posted by amok on Stack Overflow See other posts from Stack Overflow or by amok
Published on 2010-04-25T06:08:43Z Indexed on 2010/04/25 6:13 UTC
Read the original article Hit count: 208

Filed under:
|

I have a button on a view, I want to add another button next to it when the first button is touched. Therefore I need it's top left corner to do the math.

Here's what is puzzling me greatly: // this code is executed when the button is pressed

NSLog(@"X:%f",moreButton.frame.origin.x);

that returns on the first and second click the followings:

2010-04-24 22:58:25.883 iPad PopOver[8095:40b] X:-1.999002 2010-04-24 22:58:25.884 iPad PopOver[8095:40b] Y:0.000000

why and how can I get the x,y of an existing button on the view? (button created via IB)

Thanks! mE

ps: I have looked at similar posts and my code looks fine but I keep getting zeros (it's an ipad app if matters in any way)

© Stack Overflow or respective owner

Related posts about iphone

Related posts about cocoa-touch