Reply:
Reply:
Good desolate, no one, to help the landlord Top
Reply:
Xie Xie

Reply:
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:
Reply:
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:
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:
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:
Reply:
Reply:
Use uitextview of selectedRange attributes can get the position of the cursor
Reply:
But it does not determine the number of rows ah, if you can get good ordinate.
Reply:
Reply:
Reply:
Overloaded UITextView it!
Reply:
1, access to the cursor position with selectedRange thus highly
2 lines can be calculated with high
sizeWithFont3. Both division
Reply:
How come with selectedRange height ah? Only draw the character in the cursor position does not coordinate
Reply:
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:
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:
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:
Reply:
Not Bangniding
Reply:
Reply:
No comments:
Post a Comment