[英]Smooth scrolling In UICollectionView inside UICollectionViewCell
[英]Vertical scrolling on UICollectionViewCell inside the Horizontal Scrolling UICollectionView
我有两个单元格的collectionview。 一个用于登录,另一个用于分页的注册。 在每个单元格中,我需要垂直滚动。
我试图在集合视图单元格中保留垂直scrollview,但它不起作用。
在表视图中看到了很少的教程和问题放置集合视图。 但是想知道我们可以在水平滚动集合视图的单元格内部保持垂直滚动视图或任何其他选项来实现此目的
您可以将垂直滚动视图放入tableView。 只需将其放入tableViewCell的contentView,示例代码:
- (void)viewDidLoad {
[super viewDidLoad];
UITableView* tableView = [[UITableView alloc] initWithFrame:CGRectZero style:UITableViewStyleGrouped];
tableView.delegate = self;
tableView.dataSource = self;
tableView.frame = CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height);
[self.view addSubview:tableView];
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
return 1;
}
-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell* cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
UIScrollView* sv = [[UIScrollView alloc] init];
CGRect rect = CGRectZero;
rect.size.width = self.view.bounds.size.width;
rect.size.height = 60;
sv.frame = rect;
sv.contentSize = CGSizeMake(1000, 60);
UILabel* label = [[UILabel alloc] init];
label.frame = CGRectMake(0, 0, 900, 30);
label.text = @"hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello hello ";
label.adjustsFontSizeToFitWidth = true;
[sv addSubview:label];
[cell.contentView addSubview:sv];
return cell;
}
我遇到了同样的问题,这里有两种方法可以尝试:
hitTest:event
方法,添加您想要的下一个响应者的查找视图
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.