我正在尝试在subviews
子类中调整UIScrollView
,但我不想打扰滚动指示器。似乎没有任何公共(public)接口(interface)可以访问这些接口(interface),我想检查 View 是否是滚动指示器之一(以便我可以忽略它)。UIScrollView.h
声明了这两个iVar:
UIImageView* _verticalScrollIndicator;
UIImageView* _horizontalScrollIndicator;
...但是我尝试了以下操作,并出现了链接器错误:
for(UIView* v in self.subviews)
{
// Ignore the scroll-indicator views
if( (v == _horizontalScrollIndicator) ||
(v == _verticalScrollIndicator))
{
continue;
}
// View is one of mine - do stuff to it...
}
Apple显然不希望您弄乱这些,在这种情况下,它们应该做一些聪明的事情,以便从
subviews
返回的数组不包括它们(在Apple上,这并不难!),但是在那之前,我如何才能忽略它们他们? 最佳答案
这最终是我的解决方法
BOOL showsVerticalScrollIndicator = self.showsVerticalScrollIndicator;
BOOL showsHorizontalScrollIndicator = self.showsHorizontalScrollIndicator;
self.showsVerticalScrollIndicator = NO;
self.showsHorizontalScrollIndicator = NO;
// loop through self.subviews here
self.showsVerticalScrollIndicator = showsVerticalScrollIndicator;
self.showsHorizontalScrollIndicator = showsHorizontalScrollIndicator;
关于iphone - 在枚举UIScrollView的 subview 时如何排除滚动指示器?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10965754/