我有滾動查看屏幕底部。當我點擊按鈕它加載滾動視圖。但scrollview佔用完整的父視圖。我無法控制一些直接製作的視角。如果我使用scrollview,我無法處理其他按鈕操作,並單擊其他子視圖的事件。滾動查看屏蔽父視圖
代碼:
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}>
我建議您在設置內容之前和之後打印滾動視圖的框架。讓我知道輸出。大概我可以幫你解決這個問題 –
我不明白 – user2674668
爲你的滾動視圖記錄框架 –