Tom*_*m G 55 iphone objective-c scrollbar uiscrollview
可能是一个简单的!
有谁知道如何让UIScrollView的滚动条不断显示?
它在用户滚动时显示,因此他们可以看到它们所处的滚动视图的位置.
但是我希望它能够不断显示,因为用户不能立即看到滚动可用
任何建议都将受到高度赞赏.
Mon*_*ong 83
不,你不能让它们总是显示,但你可以让它们暂时闪现.
[myScrollView flashScrollIndicators];
Run Code Online (Sandbox Code Playgroud)
它们是滚动指示器,而不是滚动条.您无法使用它们滚动.
我的解决方案一直显示滚动指示器
#define noDisableVerticalScrollTag 836913
#define noDisableHorizontalScrollTag 836914
@implementation UIImageView (ForScrollView)
- (void) setAlpha:(float)alpha {
if (self.superview.tag == noDisableVerticalScrollTag) {
if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin) {
if (self.frame.size.width < 10 && self.frame.size.height > self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.height < sc.contentSize.height) {
return;
}
}
}
}
if (self.superview.tag == noDisableHorizontalScrollTag) {
if (alpha == 0 && self.autoresizingMask == UIViewAutoresizingFlexibleTopMargin) {
if (self.frame.size.height < 10 && self.frame.size.height < self.frame.size.width) {
UIScrollView *sc = (UIScrollView*)self.superview;
if (sc.frame.size.width < sc.contentSize.width) {
return;
}
}
}
}
[super setAlpha:alpha];
}
@end
Run Code Online (Sandbox Code Playgroud)
更新:此解决方案导致64位的一些问题.有关详细信息,请查看此处