开发者

UITextView not showing scroll bars

开发者 https://www.devze.com 2023-03-11 16:51 出处:网络
I have made UITextView programmatically but it is not showing the vertical and horizontal scroll bars. The code I have used is as follows,

I have made UITextView programmatically but it is not showing the vertical and horizontal scroll bars. The code I have used is as follows,

UITextView *txtView = [[UITextView alloc] initWithFrame:CGRectMake(origin, imgFrame.size.heigh开发者_高级运维t + 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];

How can I make the scrollbars show?


I think there is no regular way to make them always visible (On Purpose!).

The BOOL txtView.showsVerticalScrollIndicator=TRUE/showsHorizontalScrollIndicator only shows the bar if the scrollView is active and hides it after some milliseconds inactivity.

If you comment [txtView flashScrollIndicators]; out then it only shows it once, to show the User that there is a possibility to scroll.

I think one (ugly) way to make it possible is, to call flashScrollIndicators more often, but this is no proper solution.


Do you have any text in it? It will only show the scroll bars if the text is bigger than the size of the view.


As bizarre as it may sound, do you ever collect and remove/edit subviews of your UITextView? When calling subviews from a UITextView (or UIScrollView), it will also return its scroll bars.

0

精彩评论

暂无评论...
验证码 换一张
取 消