UITextView
을 사용하고 있는데 UITextview
하단의 공백을 제거하고 싶습니다.UITextView의 맨 아래에 공백을 제거하는 방법은 무엇입니까?
0
A
답변
1
은 당신이 원하는 결과를 얻었다 생각 ...
// Create a size with large height, but matching width to UITextView.
[myTextView setBackgroundColor:[UIColor greenColor]];
CGSize maxSize = CGSizeMake(myTextView.frame.size.width, 20);
// Determine the size needed to display the text - we just need the new height.
CGSize textSize = [myTextView.text sizeWithFont:myTextView.font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap];
// Set the UITextView's frame to the new height.
CGRect textViewRect = myTextView.frame;
textViewRect.size.height = textSize.height+13;
myTextView.frame = textViewRect;
2
이와 비슷한?
textView.text = [textView.text stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
0
난 당신이 친절하게 텍스트를 수용 할 수있는 UITextView의 크기를 조정하고자하는 추측/있으리라 믿고있어. 그렇다면, 나는 당신이 조사 제안 : 예를 들어
- (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode;
:
내가 하란으로 code.try 이상으로 업데이트 한// Create a size with large height, but matching width to UITextView.
CGSize maxSize = CGSizeMake(myTextView.frame.size.width, 9999);
// Determine the size needed to display the text - we just need the new height.
CGSize textSize = [myTextView.text sizeWithFont:myTextView.font constrainedToSize:maxSize lineBreakMode:UILineBreakModeWordWrap];
// Set the UITextView's frame to the new height.
CGRect textViewRect = myTextView.frame;
textViewRect.size.height = textSize.height;
myTextView.frame = textViewRect;
관련 문제
- 1. RelativeLayout의 맨 아래에 RelativeLayout을 배치하는 방법은 무엇입니까?
- 2. QTreeView 맨 아래에 스크롤 가능 공백을 추가하는 방법
- 3. OCaml에서 문자열의 공백을 제거하는 방법은 무엇입니까?
- 4. java에서 URL의 공백을 제거하는 방법은 무엇입니까?
- 5. CodeIgniter에서 페이지 매김의 공백을 제거하는 방법은 무엇입니까?
- 6. 텍스트에서 공백을 제거하는 WebView
- 7. 공백을 제거하는 Xpath 함수
- 8. 정규식에서 공백을 제거하는 이유는 무엇입니까?
- 9. 공백을 제거하는 정규식 도움말
- 10. DataGridView의 맨 아래에서 편집 행을 제거하는 방법은 무엇입니까?
- 11. 보기의 맨 아래에 고정 된 UIButton을 만드는 방법은 무엇입니까?
- 12. div의 맨 아래에 이미지를 표시해야합니다
- 13. PHP : 맨 아래에 변수를 읽으십시오
- 14. UITextView의 카운터를 얻는 방법은 무엇입니까?
- 15. XmlDocument에서 공백을 제거하는 방법
- 16. 후행 공백을 제거하는 이점?
- 17. 후행 공백을 제거하는 XML
- 18. 오라클 - 공백을 제거하는 방법?
- 19. 공백을 제거하는 액션 스크립트
- 20. UITextView의 헤더보기?
- 21. 기존 ASP의 전자 메일 헤더에서 공백을 제거하는 방법은 무엇입니까?
- 22. 자바에서 문자열 사이에 \ n, \ t 및 공백을 제거하는 방법은 무엇입니까?
- 23. 문자열의 특정 문자 뒤에 공백을 제거하는 가장 좋은 방법은 무엇입니까?
- 24. 탭 메뉴에서 원하지 않는 공백을 제거하는 방법은 무엇입니까?
- 25. PHP를 사용하여 javascript 파일에서 공백을 제거하는 방법은 무엇입니까?
- 26. 표보기 셀에서 행을 숨길 때 공백을 제거하는 방법은 무엇입니까?
- 27. RegexKitLite를 사용하여 두 단어 사이에 공백이나 공백을 제거하는 방법은 무엇입니까?
- 28. Drupal Captcha가 맨 위 및 맨 아래에 표시되지 않습니까?
- 29. CSS를 사용하여 공백을 제거하는 방법
- 30. 공백을 제거하는 MYSQL 업데이트 쿼리
전 - (CGSize) sizeWithFont : (UIFont *) font constrainedToSize : (CGSize) size lineBreakMode : (UILineBreakMode) lineBreakMode;를 작성해야합니다. .h 파일의 메소드? – PJR
textViewRect.height = textSize.height; 행은 오류 – PJR
을 표시합니다. 아니요, NSString 인스턴스 메서드이므로 인터페이스에 선언하지 않고 코드에 포함시킬 수 있습니다. –