如何根据通过表视图进行的选择在 uiview 中显示不同的视图控制器(请参阅说明中的图片)?
How do I display different view controllers in a uiview depending on selection through a tableview (Please see the image in description)?
我想使用具有产品列表视图的 objectiveC 创建一个 ios 应用程序。我想为此列表创建一个筛选器屏幕,它有一个表视图和另一个视图,该视图根据第一个表视图中选择的行显示不同的自定义视图控制器。我正在从流行的电子商务应用程序上传类似屏幕的屏幕截图。
你能帮我解决一下如何处理我必须在 uiview 中显示不同视图控制器的部分吗?提前致谢!
如果要随机播放的自定义视图控制器很少,请使用 container view
使用scrollView这个很容易达到你的要求:)
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];
}
如果您有多个视图控制器,只需根据需要调整此代码
我想使用具有产品列表视图的 objectiveC 创建一个 ios 应用程序。我想为此列表创建一个筛选器屏幕,它有一个表视图和另一个视图,该视图根据第一个表视图中选择的行显示不同的自定义视图控制器。我正在从流行的电子商务应用程序上传类似屏幕的屏幕截图。
你能帮我解决一下如何处理我必须在 uiview 中显示不同视图控制器的部分吗?提前致谢!
如果要随机播放的自定义视图控制器很少,请使用 container view
使用scrollView这个很容易达到你的要求:)
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];
}
如果您有多个视图控制器,只需根据需要调整此代码