UIScrollView
をcustomViewに追加して、右にcontentSize
を設定しますが、scrollViewはスクロールできません。Q:UIScrollViewをUIViewに追加すると、scrollViewがスクロールできない
これは私のコードです:
_scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 44, self.bounds.size.width, self.bounds.size.height - 44)];
// _scrollView.translatesAutoresizingMaskIntoConstraints = NO;
// _scrollView.userInteractionEnabled = NO;
_scrollView.contentSize = CGSizeMake(3 * self.bounds.size.width, self.bounds.size.height - 44 + 500);
_scrollView.contentOffset = CGPointMake((_orginSelectedIndex)*(self.bounds.size.width), 44);
_scrollView.pagingEnabled = YES;
_scrollView.scrollEnabled = YES;
[self addSubview:_scrollView];
/* add tableviews */
for (int i = 0 ; i < _titlesArr.count; i ++) {
UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(i * self.bounds.size.width, 44, self.bounds.size.width, self.bounds.size.height - 44) style:UITableViewStylePlain];
tableView.tag = 200 + i;
tableView.backgroundColor = RandColor;
[self addSubview:tableView];
}
そして私はまた私のスクロールのcontentSize
をログに記録します。
NSLog(@"%@-s", NSStringFromCGSize(lml_pager.scrollView.contentSize));
があります示しています
2016-06-21 17:39:07.272 LMLViewPager[7381:312567] {1125, 1059}-s
誰かが問題が何であるかを知っていますか?自分のコードでautolayoutを使っていませんでした。
そして、私の絵のトークンはデバッグにあります: もちろん、それだけで1 tableView
を追加し、私の_titlesArr
カウントは3 picture
ビューとスクロールビューのuserInteractionEnabled = YES; – lme