我有屏幕底部的滚动视图。当我单击按钮时,它会加载滚动视图。但是滚动视图占据了完整的父视图。我无法控制某些 rectMake 的底部视图。如果我使用滚动视图,我将无法处理其他一些按钮操作和其他子视图的单击事件。
代码:
scrollview=[[UIScrollView alloc]initWithFrame:CGRectMake(0,0,320,self.view.frame.size.height)];
scrollview.scrollEnabled=YES;
for (int i = 0; i<[self.array count]; i++ ) {
NSLog(@"index %d",i);
imgView1=[[UIButton alloc]initWithFrame:CGRectMake(20+(i*74), 500, 72, 72)];
[imgView1 setTag:i+1];
[imgView1 addTarget:self action:@selector(Clicked:) forControlEvents:UIControlEventTouchUpInside];
[imgView1 setImage:((Mysof *)[self.array objectAtIndex:i]).photo forState:UIControlStateNormal];
[scrollview addSubview:imgView1];
}
[scrollview setContentSize:CGSizeMake(CGRectGetMaxX(imgView1.frame),self.view.frame.size.height)];
[self.view addSubview:scrollview];
日志:
scroll is <UIScrollView: 0x1f03d550; frame = (0 0; 320 568); clipsToBounds = YES; gestureRecognizers = <NSArray: 0x1f037090>; layer = <CALayer: 0x1f036670>; contentOffset: {0, 0}>