2016-04-02 64 views
0

我在設置內容大小後沒有顯示垂直滾動指示器時出現問題。UIScrollView垂直滾動指示器

看到這樣的代碼:

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]; 

任何幫助,請

回答

0

我不知道爲什麼,但我嘗試這一點,它的工作以及

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

首先,什麼是你的滾動視圖的高度,如果滾動視圖的高度>其內容的大小,然後滾動視圖無法滾動。

+0

滾動型身高=視圖HEIGH –

+0

的NSLog(@ 「%F」,self.scrollView.frame.size.height)= 628.000000在iPhone 6加 –

+0

NSLog(@「%f」,self.scrollView.contentSize.height); = 1820.333333 –