TWB_Systems
asked on
Get the top left coordinates of a UITextView
I have a UITextView that is a part of scrollView.. What I want to do is get the top left coordinates of the TextView when the user clicks a button. Can this be accomplished?
Thanks,
Matt
Thanks,
Matt
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In order to avoid misunderstanding: myView in the previous comment is the scrollView from your question, it does not change its position and so the bounds and the size do not change.
ASKER
Thanks for your reply... Do you have convert rect.origin.y to an integer? It keeps returning 0 for me when I try to display with NSLog("Y is: %i", rect.origin.y);
If it's float, print it as float: %f.
NSLog("Y is: %f", rect.origin.y);
If you need it as int, cast it same way as in C: (int), for example:
NSLog("Y is: %i", (int)(rect.origin.y));
This origin is NSPoint, it is a structure, but knows how to "explain itself" with NSStringFromPoint(thePoint ).
So you can use:
NSLog(@"Origin %@", NSStringFromPoint(rect.ori gin));
It is not a correct way to ask the related question, please don't do it this way.
NSLog("Y is: %f", rect.origin.y);
If you need it as int, cast it same way as in C: (int), for example:
NSLog("Y is: %i", (int)(rect.origin.y));
This origin is NSPoint, it is a structure, but knows how to "explain itself" with NSStringFromPoint(thePoint
So you can use:
NSLog(@"Origin %@", NSStringFromPoint(rect.ori
It is not a correct way to ask the related question, please don't do it this way.
ASKER
Thanks for your help!
I used the following:
CGRect rect = [scrollView bounds];
NSLog(@"My y is: %f", rect.origin.y);
I used the following:
CGRect rect = [scrollView bounds];
NSLog(@"My y is: %f", rect.origin.y);
You are welcome.
I thought you work on Mac and so said about NSRect and about NSStringFromPoint. :)
So please mention it next time and I will not confuse you in my comments.
Best regards
I thought you work on Mac and so said about NSRect and about NSStringFromPoint. :)
So please mention it next time and I will not confuse you in my comments.
Best regards