0
다음 코드 조각 (source)을 사용하여 해당 내용에 맞게 UITextView
의 크기를 조정했습니다.내용에 맞게 크기를 조정할 수있는 UITextView
UITextView* textView = [[UITextView alloc]initWithFrame:CGRectMake(0.0f,0.0f,300.0f,10.0f)];
[self.view addSubview:textView];
textView.text = @"Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s";
CGRect frame = textView.frame;
frame.size.height = textView.contentSize.height;
textView.frame = frame;
내 문제는 프로그래밍 방식으로 UITextView
을 만들고 싶지 않다는 것입니다. Interface Builder에서 코드를 추가하고 @property
을 통해 참조하면 위 코드가 작동하지 않습니다. frame
은 null
을 반환합니다. 이 코드를 viewDidLoad
안에 넣었으므로 UITextView
이 초기화되었거나 뷰 컨트롤러에 아직 추가되지 않았기 때문에 (?)
프로그래밍 방식으로 UITextView
을 만들지 않고도이 작업을 수행 할 수있는 다른 방법이 있습니까? 당신은 인터페이스 빌더에서 준비해 놓은 재산이있는 경우
안녕하세요. 네,이 줄을 주석 처리하고 연결을 다시 확인했습니다. 비록 아무 소용이 없다. – Isuru