0
在我的项目中,我在底部滚动并在顶部显示表格。 滚动视图里面我添加了10个按钮,每个按钮我都有平移手势在屏幕上移动。当按钮与表相交时,会在tableview中添加图片。在UIScrollview中为UIButton添加UIPangesture以移动到所有视图
但锅工作scroll.how内,使其搬过来查看
我的编码是:
downscroll=[[UIScrollView alloc]initWithFrame:CGRectMake(24, 635, 980, 100)];
downscroll.backgroundColor=[UIColor redColor];
downscroll.contentSize=CGSizeMake(990, 100);
[self.view addSubview:downscroll];
for(int i=1;i<=8;i++)
{
b1=[UIButton buttonWithType:UIButtonTypeCustom];
b1.frame=CGRectMake(30+px, 0, 80, 80);
[b1 setImage:[UIImage imageNamed: [NSString stringWithFormat:@"Icon%i.png",i]] forState:UIControlStateNormal];
[downscroll addSubview:b1];
// [self.view sendSubviewToBack:b1];
// [self.view bringSubviewToFront:b1];
[groupbutton addObject:b1];
panRecognizer3= [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(move:)];
[b1 setUserInteractionEnabled:YES];
b1.exclusiveTouch=YES;
img.tag=i;
[b1 addGestureRecognizer:panRecognizer3];
px=px+120;
}
当我直接加我的按钮没有滚动滚动视图它的工作原理fine.But我需要添加按钮滚动视图 请帮助正确的代码。提前致谢。