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我需要添加按鈕滾動視圖 請幫助正確的代碼。提前致謝。