2
A
답변
2
당신은
sizeWithFont:constrainedToSize:
하여 문자열의 폭을 계산하고 폭으로 나누면이 하위 문자열을 사용 커서 위치에서
NSRange cursorPosition = [tf selectedRange];
문자열에 의해 약간의 계산 찾을 수 커서 위치 할 필요가 귀하의 TextView 너비 중 .. 그것은 당신에게 커서가 줄을 줄 것입니다 ... 논리적으로 올바른 것 같습니다 ... 그것을 시도하지 않은 ... 그것이 작동하는지 아닌지 알려 주시기 바랍니다 ..
1
이와 비슷한 것 :
- (int) getCurrentLine: (UITextView *) textView{
int pos = textView.selectedRange.location;
NSString *str =textView.text;
NSCharacterSet *charset = [NSCharacterSet whitespaceAndNewlineCharacterSet];
int num = pos;
for (; num< str.length; num++){
unichar c = [str characterAtIndex:num];
if ([charset characterIsMember:c]) break;
}
str = [str substringToIndex:num];
CGSize tallerSize = CGSizeMake(textView.frame.size.width - 16, 999999);
CGSize lc1 = [@"Yyg" sizeWithFont: textView.font constrainedToSize:tallerSize lineBreakMode:UILineBreakModeWordWrap];
CGSize lc = [str sizeWithFont: textView.font constrainedToSize:tallerSize lineBreakMode:UILineBreakModeWordWrap];
lc.height = lc.height/lc1.height;
return lc.height;
}
관련 문제
- 1. iPhone UITextView 위치 상대
- 2. textview.selectedRange.location in UITextview show 2147483647
- 3. UITextView 스크롤
- 4. 맞춤 UITextView
- 5. UITextView inputView
- 6. transparent UITextView
- 7. UITextView 업데이트
- 8. UITextView autoSize
- 9. 이 UITextView 문제를 해결하는 방법
- 10. UITextView 스 와이프 제스처
- 11. UITextView memory leak
- 12. 아이폰 - UITextView 메모리 누수
- 13. UITableViewCell UITextView 스크롤 문제
- 14. UITextView - 선택한 텍스트 수정
- 15. UITextView 키보드 숨기기 문제
- 16. UIScrollview + UItextview 터치 이벤트
- 17. 포커스가있는 UITextView 설정
- 18. UITextView 서식있는 텍스트?
- 19. 문제 setText UITextView
- 20. 프로그래밍 방식으로 uitextview 스크롤
- 21. 동적 확장 UITextView
- 22. iOS의 UITextView 자동 스크롤
- 23. 아이폰 UITextView 예외
- 24. UITextView - 세로 스크롤을 비활성화하십시오.
- 25. 관련 UITextView 관련 질문
- 26. UITextView 내용을 NSString에 저장하십시오.
- 27. iphone UitextView 텍스트 잘림
- 28. UITextView 배경 이미지
- 29. 키보드, 방향 및 UITextView
- 30. UITextView IB에서가 아니라 시뮬레이터