在我的应用程序中,我使用 ScrollView 来显示数据列表(通过为列表中的每个条目添加每个 View ),当将新条目添加到数据列表中时,我将一个新 View 作为 subview 添加到 ScrollView 中,我使用 subViews 计数来定位新添加的 View ,我遇到了一个问题,我的 ScrollView 有两个 imageView。
我在-viewDidLoad中检查了它
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"subvs %@",[sampleScroll subviews]);
}
这是我的控制台窗口
subvs (
"<UIImageView: 0x72b9610; frame = (233 121; 7 7); alpha = 0; opaque = NO; autoresize = TM; userInteractionEnabled = NO; animations = { contentsCenter=<CABasicAnimation: 0x72dd8b0>; position=<CABasicAnimation: 0x72e2520>; }; layer = <CALayer: 0x72b96b0>>",
"<UIImageView: 0x72e2ae0; frame = (233 121; 7 7); alpha = 0; opaque = NO; autoresize = LM; userInteractionEnabled = NO; animations = { contentsCenter=<CABasicAnimation: 0x72b7c50>; position=<CABasicAnimation: 0x72b7ce0>; }; layer = <CALayer: 0x72e2b80>>"
)
编辑:-我通过在 xib 中拖放添加了scrollView
最佳答案
这些是用 ScrollView 初始化的水平和垂直滚动指示器(默认情况下是 UIImageviews)
如果您不想要,可以像这样删除它们
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"subvs %@",[sampleScroll subviews]);
for(UIView *view in sampleScroll.subviews){
[view removeFromSuperview];
}
}
关于ios - 两个 ImageView 添加到我使用对象库添加的 ScrollView 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16668959/