티스토리 뷰
CGRect frame = _textView.frame;
frame.size.height = _textView.contentSize.height;
_textView.frame = frame;
Edit: sizeThatFits returns the size but does not actually resize the component. I'm not sure if that's what you want, or if
[textView sizeToFit]
is more what you were looking for. In either case, I do not know if it will perfectly fit the content like you want, but it's the first thing to try.
ps > 테이블 생성시 높이 지정을 위해서 UITextView 생성을 하고 높이를 구하려 할때는 cellForRowAtIndexPath 에서 셀 생성 하듯이 하나 만들어서... (heightForRowAtIndexPath 에 임의로 실제 사용하는 셀을 생성해서 적용해보고 구해오기)
ps2 > sizeToFit 날리기 전에 사이즈 항상 늘려놓기(셀 재사용으로 인해 전에 설정이 이후에 영향을 미침)
위 방법은 테이블이 많이 길어지면 느려서..
ps2 > sizeToFit 날리기 전에 사이즈 항상 늘려놓기(셀 재사용으로 인해 전에 설정이 이후에 영향을 미침)
위 방법은 테이블이 많이 길어지면 느려서..
CGSize maximumSize = CGSizeMake(300, 9999);
NSString *dateString = @"The date today is January 1st, 1999";
UIFont *dateFont = [UIFont fontWithName:@"Helvetica" size:14];
CGSize dateStringSize = [dateString sizeWithFont:dateFont
constrainedToSize:maximumSize
lineBreakMode:self.dateLabel.lineBreakMode];
CGRect dateFrame = CGRectMake(10, 10, 300, dateStringSize.height);
self.dateLabel.frame = dateFrame;
이렇게도 가능
'나름 프로그래밍? > Objective-C' 카테고리의 다른 글
NSAutoreleasePool 활용 (0) | 2010.12.30 |
---|---|
view 에 존재하는 서브뷰 좌악 훑어 오기 (0) | 2010.12.28 |
iOS 버젼 검사 (0) | 2010.12.26 |
NSZombieEnabled 설정 하기 (0) | 2010.12.14 |
자동 잠금(Auto Lock) 싱행중 방지 - 백라이트 유지 (0) | 2010.11.27 |