I want to create an ios app, using objectiveC, which has a products list view. I am looking to create a filter screen for this list, which has a tableview and another view which displays different custom viewcontrollers depending on the row selected in the first tableview. I am uploading a screenshot of a similar screen from a popular ecommerce app.
Can you please help me on how to handle the part where I will have to display different viewcontrollers in the uiview. Thanks in advance!
Use scrollView for this it is easy to achieve your requirements:)
scrollView =[[UIScrollView alloc]init];
scrollView.frame =CGRectMake(0, 100, self.view.frame.size.width, self.view.frame.size.height - 60);
scrollView.pagingEnabled=YES;
scrollView.delegate=self;
scrollView.bounces=NO;
scrollView.showsHorizontalScrollIndicator = YES;
scrollView.showsVerticalScrollIndicator = NO;
scrollView.scrollsToTop=NO;
scrollView.indicatorStyle=UIScrollViewIndicatorStyleWhite;
[self.view addSubview:scrollView];
scrollView.contentSize=CGSizeMake(2*scrollView.frame.size.width, scrollView.frame.size.height - 60);
collectionantZ *homeScreen =[self.storyboard instantiateViewControllerWithIdentifier:@"yyy"];
Antzclubtableview *antzClub =[self.storyboard instantiateViewControllerWithIdentifier:@"xxx"];
tableView1.view.frame=CGRectMake(0,19,scrollView.frame.size.width, scrollView.frame.size.height);
tableView2.view.frame=CGRectMake(scrollView.frame.size.width,19,scrollView.frame.size.width, scrollView.frame.size.height);
[scrollView addSubview:tableView1.view];
[scrollView addSubview:tableView2.view];
[self addChildViewController:tableView1];
[self addChildViewController:tableView2];
- (IBAction)tableView1:(id)sender {
[scrollView setContentOffset:CGPointMake(0,0.) animated:YES];
}
- (IBAction)tableView2:(id)sender {
[scrollView setContentOffset:CGPointMake(1 *scrollView.frame.size.width,0.) animated:YES];
}
if you have multiple view controller just adjust this code as per your need
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.