Saturday, November 30, 2013

UITextView determine the cursor in the first few lines, has come of

As stated, there are points to come
Reply:
The reply was deleted at the moderator 2012-07-08 08:54:55

Reply:
Good desolate, no one, to help the landlord Top
Reply:
reference to the second floor of the reply:
good desolate, no one, to help the landlord to Top

Xie Xie
Reply:
The reply was deleted at the moderator 2012-07-09 08:21:30

Reply:
Does not seem easy to handle, can only know the location, how that corresponds to the number of lines, it seems that was calculated based on the number of characters per line?
Reply:
First support topics where are you?
Reply:
http://blog.csdn.net/liyanbo1984/article/details/5807095
Did not test for reference
Reply:
The reply was deleted at the moderator 2012-07-09 12:52:43

Reply:
references, 5th Floor reply:
does not seem easy to handle, can only know the location, how that corresponds to the number of lines, it seems that was calculated based on the number of characters per line?

Location How to get? With the position easier to handle
Reply:
 
- (Int) getCursorPointY: (UITextView *) curtextView
{
CGPoint cursorPoint;
int Len = curtextView.selectedRange.location;
NSString * stringToCursor = [curtextView.text substringToIndex: Len];
NSArray * partStrArr = [stringToCursor componentsSeparatedByString: @ "\ n"];
int row = [partStrArr count];
CGSize fontsize = [@ "me" sizeWithFont: [curtextView font]];
for (NSString * partStr in partStrArr)
{
CGSize partStrSize = [partStr sizeWithFont: [curtextView font] constrainedToSize: curtextView.contentSize lineBreakMode: UILineBreakModeCharacterWrap];
NSLog (@ "partStrSize.width =% f, partStrSize.height =% f", partStrSize.width, partStrSize.height);
int rowG = partStrSize.height / fontsize.height;
if (rowG> 1) {
rowG - = 1;
row + = rowG;
}

}

cursorPoint.y = (row -1) * fontsize.height;

return (int) (cursorPoint.y);
}

This code can be accurately positioned over 4.3 years, 5.1 years but will have to locate each error, and the error is cumulative.
Reply:
This. . . . Not used, do not know.
Reply:
This really did not do ... friendship Bangding ...
Reply:
Look at this okay:
UITextRange * startTextRange = [textview characterRangeAtPoint: CGPointZero];
CGRect caretRect = [textview caretRectForPosition: startTextRange.end];
CGFloat topMargin = CGRectGetMinY (caretRect);
CGFloat lineHeight = CGRectGetHeight (caretRect);

caretRect = [textview caretRectForPosition: textview.selectedTextRange.end];
CGFloat caretTop = CGRectGetMinY (caretRect);
NSInteger lineIndex = (caretTop - topMargin) / lineHeight;
Reply:
reference to the 13th floor of the reply:
look at this okay:
UITextRange * startTextRange = [textview characterRangeAtPoint: CGPointZero];
CGRect caretRect = [textview caretRectForPosition: startTextRange.end];
CGFloat topMargin = CGRectGetMin ......

No, the first one on the runtime error
Reply:
Amount, which is the method ios5 and can not be used for ios4, it seems you need a comprehensive look
Reply:
reference to the 15th floor Reply:
amount, which is the method ios5 and can not be used for ios4, it seems you need a comprehensive look

Ah, I tried, problems and methods before I made the same number of rows whenever increase, there will be some errors, and finally become the first N lines was originally prompted the N-1 lines.
Reply:
The reply was deleted on 2012-07-13 08:19:33 moderator

Reply:
The reply was deleted on 2012-07-13 08:17:39 moderator

Reply:
Use uitextview of selectedRange attributes can get the position of the cursor
Reply:
reference to the 19th floor Reply:
use uitextview of selectedRange attributes can get the cursor position

But it does not determine the number of rows ah, if you can get good ordinate.
Reply:
The reply was deleted at the moderator 2012-07-24 09:23:29

Reply:
The reply was deleted at the moderator 2012-07-24 09:46:00

Reply:
Overloaded UITextView it!
Reply:
reference to the 20th floor Reply:
reference to the 19th floor Replies:

Use uitextview of selectedRange attributes can get the cursor position

But it does not determine the number of rows ah, if you can get good ordinate.

1, access to the cursor position with selectedRange thus highly
2 lines can be calculated with high
sizeWithFont3. Both division
Reply:

reference to the 24th floor of the reply:
reference to the 20th floor Replies:

19th Floor cited reply:

Use uitextview of selectedRange attributes can get the cursor position

But it does not determine the number of rows ah, if you can get good ordinate.

1, access to the cursor position with selectedRange thus highly
2 lines can be calculated with high
sizeWithFont3. Both divide

How come with selectedRange height ah? Only draw the character in the cursor position does not coordinate
Reply:
The reply was deleted at the moderator 2012-08-03 09:13:56

Reply:
Thank you, landlord good!
Reply:
Use uitextview of selectedRange attributes can get the cursor position

Reply:
Can you get a look at the width of each character, because the width of each character is not the same. But you have to judge this do? Talk about your purpose.
Reply:
reference to the 29th floor of the reply:
Can you get a look at the width of each character, because the width of each character is not the same. But you have to judge this do? Talk about your purpose.

For example, a chat software provides three lines of UITextview, however, the user's cursor reaches the second or third row, UITextview automatically scroll up when
Reply:
It's not on their own rolling it?
Reply:
cited 31 F reply:
it is not rolling it on their own?

I want to maintain the cursor in the second line, which is the second line on the scroll. Currently only need to determine the number of rows to get to the longitudinal coordinates of the cursor, the key is how to get
Reply:
The reply was deleted at the moderator 2012-08-10 11:58:35

Reply:
Not Bangniding
Reply:
The reply was deleted at the moderator 2012-08-10 16:12:28

Reply:
The reply was deleted at the moderator 2012-08-11 09:38:04

No comments:

Post a Comment