Friday, 15 January 2010

ios - Getting real position of UItextField in UIScrollView -



ios - Getting real position of UItextField in UIScrollView -

i have series of uitextviews in uiscrollview. number of textviews there depends on user, there can many wants.

i assign each uitextview (which add together nsmutablearray) same uitapgesturerecogniser. when uitextview tapped on, line drawn connects textfield point touched on screen user. works fine, except fact when scroll down, wrong y coordinate starting point, set in way:

cgpoint coords; coords.y = textname.frame.origin.y + 15;

...where textname sender of gesture

is there way coordinate of actual screen, without considering uitextview in uiscrollview??

the uiview class provides methods convert coordinates 1 view another.

to convert view's origin screen coordinates do:

cgpoint screenorigin = [someview convertpoint:someview.bounds.origin toview:nil];

passing nil toview means convert screen coordinates.

in case, replace someview textname.

ios xcode

No comments:

Post a Comment