Search code examples
iosuiscrollviewvertical-scrolling

UIScrollView Vertical Scroll Indicator


I have a problem with vertical scroll indicator its not showing after I set content size.

see this code:

    UITextView *textView = [[UITextView alloc] init];
    [textView setAttributedText:attributeString];
    [textView setFrame:CGRectMake(10, 0, self.view.frame.size.width -20, 100)];

    [textView sizeToFit];
    [textView setFrame:CGRectMake(10, 10, self.view.frame.size.width -20,
                                        textView.frame.size.height +15)];

    [self.scrollView addSubview:textView];
    [self.scrollView setContentSize:CGSizeMake(self.scrollView.frame.size.width,
                                               textView.frame.size.height +20)];

    [self.scrollView scrollRectToVisible:CGRectMake(0, 0, 
                                                   self.scrollView.bounds.size.width,
                                                   self.scrollView.bounds.size.height)
                                                   animated:YES];

    [self.scrollView setScrollEnabled:YES];
    [self.scrollView setShowsVerticalScrollIndicator:YES];

any help please


Solution

  • I don't know why but I try this and it's working well

    [self.scrollView setScrollEnabled:YES]; 
    [self.scrollView setShowsVerticalScrollIndicator:NO];     
    [self.scrollView setShowsVerticalScrollIndicator:YES];