카테고리 없음
[iOS] 가장자리에서 가장자리까지 제외 경로가있는 UiTextView로 인해 모든 텍스트가 사라집니다.
행복을전해요
2021. 1. 19. 10:03
나는 똑같은 문제를 만났지만 다행히도 그것을 해결하기 위해 \ n \ r \ n \ r 's를 입력하고 있습니다. 속임수는 알고 있지만 작동합니다.
-------------------결국 스토리 보드가되었습니다. 보기에서 UiTextView 만 꺼내고 문제를 해결하는 것처럼 프로그래밍 방식으로 초기화했습니다.
-(void) viewDidLoad{
self.textView=[[UITextView alloc] init];
self.textView.translatesAutoresizingMaskIntoConstraints=NO;
[self.view addSubview:self.textView];
NSDictionary* views = @{@"textView": self.textView};
NSArray* vContrains=[NSLayoutConstraint constraintsWithVisualFormat:@"V:|-50-[textView]-50-|" options:NSLayoutFormatAlignAllLeft metrics:nil views:views];
NSArray* hContrains=[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-50-[textView]-50-|" options:NSLayoutFormatAlignAllLeft metrics:nil views:views];
[self.view addConstraints:vContrains];
[self.view addConstraints:hContrains];
}
-------------------
textView.textContainer.lineFragmentPadding = 0
textView.textContainerInset = UIEdgeInsetsZero
textView.contentInset = UIEdgeInsetsZero
도움이 될 수 있습니다.
나는 스위프트로 비슷한 문제를 해결했는데, 해결책은 스위치와 objective-c
예제로 다른 스레드를 읽은 후에 나온다 .
.NET과 함께 UITextView가 Scrolling Enabled = true
있습니다. 스크롤이 없으면 문제가 없지만이 기능이 필요합니다.
- 스크롤링 enable = true로 표준 설정을 사용했습니다.
let path = UIBezierPath(rect: myview.frame)
textView.textContainer.exclusionPaths = [path]
self.textView.addSubview(myview)
- UITextView 텍스트를 변경할 때 스크롤을 비활성화합니다.
func setText( message: String ) {
textView.isScrollEnabled = false
textView.text = message
textView.isScrollEnabled = true
}
이것은 내 문제를 해결합니다. 도움이되기를 바랍니다.
출처
https://stackoverflow.com/questions/22008779