問題描述
我有一個 UIScrollView,我使用它動態創建和調整大小...
I have a UIScrollView which I create and size dynamically using...
scrollView.contentSize = CGSizeMake(scrollView.frame.size.width , length);
然后我將 subviews
添加到 UIScrollView
.我確實有 scrollView.showsVerticalScrollIndicator = YES;
I then add subviews
to the UIScrollView
.
I do have scrollView.showsVerticalScrollIndicator = YES;
滾動時滾動指示器永遠不會出現.
When scrolling the scroll indicator never appears.
即使我調用 [scrollView flashScrollIndicators]
也沒有任何反應.
Even if I call [scrollView flashScrollIndicators]
nothing happens.
想法?
推薦答案
遇到了同樣的問題,找不到原因.最后一個答案給出了最后的提示:每當我添加新的子視圖時,我首先從滾動視圖中刪除所有現有的子視圖(顯然還有滾動指示器).
Had the same problem and couldn't find the cause. The last answer gave the final hint: whenever I added new subviews I first removed all existing subviews from the scrollview (and apparently also the scroll indicators).
檢查我的循環后,如果子視圖確實是我想要刪除的那種,滾動指示器就會出現:
After checking in my loop, if the subview really was of the kind I wanted to be removed the scroll indicators showed up:
for (NSObject * subview in [[[scrollView subviews] copy] autorelease]) {
if ([subview isKindOfClass:[MySubView class]]) {
[(MySubView*)subview removeFromSuperview];
}
}
更新:將代碼更改為 Nikolai 的建議
Update: changed code to Nikolai's suggestion
這篇關于UIScrollView 不顯示滾動指示器的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!