2014-02-07 17 views
0

我有一個簡單的textView誰的數據被動態填充。我想調整textview的高度,一旦填充數據,以便我沒有看到垂直滾動,也沒有文本獲取clipped.i有兩個文本字段喜歡興趣愛好和感興趣和相應的標籤,如愛好和interested.Yesterday也張貼了這個Query.But我沒有得到任何解決方案。我想顯示感興趣的標籤和感興趣的textview自動基於愛好textview.Please幫我任何人。我昨天開始討論這個問題。請給我指導任何人。提前致謝。如何在ios中動態顯示AutoExpand UITextView

tViewhobbies=[[UITextView alloc]initWithFrame:CGRectMake(10, 330, 300, 60)]; 
tViewhobbies.backgroundColor=[UIColor clearColor]; 
tViewhobbies.layer.cornerRadius=5; 
[tViewhobbies setFont:[UIFont systemFontOfSize:13.0]]; 
[tViewhobbies setUserInteractionEnabled:NO]; 
tViewhobbies.font=[UIFont systemFontOfSize:16.0]; 
tViewhobbies.backgroundColor=[UIColor colorWithRed:0.662745 green:0.662745 blue:0.662745 alpha:0.5]; 
tViewhobbies.delegate=self; 
tViewhobbies.scrollEnabled=YES; 
[scrollView addSubview:tViewhobbies]; 
lblInterests = [[UILabel alloc]initWithFrame:CGRectMake(10, 370, 300, 20)];    
[email protected]"Interests"; 
lblInterests.font=[UIFont systemFontOfSize:16.0]; 
lblInterests.textColor=[UIColor colorWithRed:153.0f/255.0f green:153.0f/255.0f blue:153.0f/255.0f alpha:1]; 
[scrollView addSubview:lblInterests]; 

tViewInterests=[[UITextView alloc]initWithFrame:CGRectMake(10, 390, 300, 60)]; 
tViewInterests.backgroundColor=[UIColor clearColor]; 
[tViewInterests setFont:[UIFont systemFontOfSize:13.0]]; 
[tViewInterests setUserInteractionEnabled:NO]; 
tViewInterests.font=[UIFont systemFontOfSize:16.0];  
tViewInterests.backgroundColor=[UIColor colorWithRed:0.662745 green:0.662745 blue:0.662745 alpha:0.5]; 
tViewInterests.delegate=self; 
tViewInterests.scrollEnabled=YES; 
[scrollView addSubview:tViewInterests]; 
+2

不要問同樣的問題兩次。 http://stackoverflow.com/questions/21601478/autoexpand-uitextview-height-dynamically-in-ios – matt

回答

0

你只需要設置

[tViewInterests sizeToFit]; 
[tViewInterests layoutIfNeeded]; 
相關問題