2011-06-08 167 views
2

我已經通過編程創建了UITextView,但沒有顯示垂直和水平滾動條。我使用的代碼如下,UITextView不顯示滾動條

UITextView *txtView = [[UITextView alloc] initWithFrame:CGRectMake(origin, imgFrame.size.height + 10, mScrollView.frame.size.width, 300)]; 
txtView.font = [UIFont fontWithName:@"HelveticaNeue" size:12]; 
txtView.textColor = [UIColor blackColor]; 
txtView.textAlignment = UITextAlignmentLeft; 
txtView.editable = NO; 
txtView.scrollEnabled = YES; 
txtView.backgroundColor = [UIColor clearColor]; 
[txtView setAutoresizingMask:UIViewAutoresizingFlexibleWidth]; 
//[txtView flashScrollIndicators]; 
[txtView setText:[mDescArr objectAtIndex:index]]; 
[mScrollView addSubview:txtView]; 
[txtView release]; 

如何使滾動條顯示?

回答

3

你有任何文字嗎?如果文本大於視圖的大小,它將只顯示滾動條。

3

我認爲沒有固定的方法讓它們始終可見(On Purpose!)。

BOOL txtView.showsVerticalScrollIndicator=TRUE/showsHorizo​​ntalScrollIndicator僅在scrollView處於活動狀態時顯示條並在幾毫秒不活動後隱藏它。

如果您評論[txtView flashScrollIndicators];出,那麼它只顯示一次,以顯示用戶有可能滾動。

我認爲一種(醜陋的)方法可以更頻繁地調用flashScrollIndicators,但這不是一個合適的解決方案。

0

聽起來很奇怪,你有沒有收集和刪除/編輯你的UITextView的子視圖?從UITextView(或UIScrollView)調用子視圖時,它也會返回滾動條。