Reputation: 441
I have collectionview with two cell. One for login, another signup which works like pagination. In each cell I need to scroll vertically.
I tried to keep a vertical scrollview inside the collection view cell but its not working.
Have seen few tutorial & question putting collection view inside table view. But want to know can we keep vertical scroll view inside cell of horizontal scrolling collectionview or any other option to achieve this
Upvotes: 1
Views: 947
Reputation: 1
I encountered the same problem, here are two methods you could try:
hitTest:event
method, add find view that you want next responderUpvotes: 0
Reputation: 1297
You can put the vertical scroll view into a tableView. Just put it into the contentView of the tableViewCell, sample code:
- (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;
}
Upvotes: 0