0
我正在使用具有動態任意長度數據的Textview。我想將scrollview的大小設置爲大於Textview的大小。如何將scrollview的大小設置爲textview的大小?
如何將scrollview的大小設置爲Textview的大小?
在此先感謝....
我正在使用具有動態任意長度數據的Textview。我想將scrollview的大小設置爲大於Textview的大小。如何將scrollview的大小設置爲textview的大小?
如何將scrollview的大小設置爲Textview的大小?
在此先感謝....
前一段時間,我發現下面的代碼在互聯網上,它工作得很好:
- (float) calculateHeightOfTextFromWidth:(NSString*) text: (UIFont*)withFont: (float)width :(UILineBreakMode)lineBreakMode
{
[text retain];
[withFont retain];
CGSize suggestedSize = [text sizeWithFont:withFont constrainedToSize:CGSizeMake(width, 1000.0) lineBreakMode:lineBreakMode];
[text release];
[withFont release];
NSLog(@"%f", suggestedSize.height);
return suggestedSize.height;
}
我用這個在我自己的應用程序是這樣:
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width, [self calculateHeightOfTextFromWidth:thetext :[UIFont fontWithName:@"Helvetica" size:17.0] :320 :UILineBreakModeWordWrap]);
Thnks working fine now .... – 2010-11-12 05:37:40