简体   繁体   English

如何根据通过表视图的选择在uiview中显示不同的视图控制器(请参见说明中的图像)?

[英]How do I display different view controllers in a uiview depending on selection through a tableview (Please see the image in description)?

I want to create an ios app, using objectiveC, which has a products list view. 我想使用ObjectiveC创建一个具有产品列表视图的ios应用。 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. 您能帮我处理如何在uiview中显示不同的ViewController的部分吗? Thanks in advance! 提前致谢!

如果您很少有自定义视图控制器可以随机播放,请使用容器视图

Use scrollView for this it is easy to achieve your requirements:) 为此,使用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];

in button Action do this: 在按钮动作中执行以下操作:

- (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 如果您有多个视图控制器,只需根据需要调整此代码

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在UITableViewController中显示无数据启动UIView? 从tableView添加和删除视图? - How do I display a no-data splash UIView in a UITableViewController? Add and remove view from tableView? 如何避免将一百万个视图控制器用于表视图列表? - How do I avoid using a million view controllers for tableview list? 导航不同的视图控制器/表视图控制器时,如何在 TableViewController 上保存 UISwitches 的状态? - How can I save the state of UISwitches on a TableViewController when navigating through different view controllers/table view controllers? 如何根据tableView单元格的选择在UIViewController中加载不同的PDF文件? - How to load different PDF files in a UIViewController depending on the selection of tableView cell? 我如何选择其他详细视图控制器? - How do I segue to different detail view controllers? 在 TableView 控制器中将视图显示为内部应用程序通知 - Display view as inside app notification in TableView Controllers 如何将表格视图嵌入到UIView中,类似于在iBooks中完成字体选择的方式? - How do I embed a table view within a UIView similar to how it's done in iBooks for font selection? 我如何获得这样的视图控制器? (将其中一个滑开,但仍可以部分看到) - How do I get view controllers like this? (slide one out of the way but still partially see it) 如何获得我的TableView选择以打开模式视图? - How do I get my TableView selection to open my modal view? UISegmentedControl显示不同的视图控制器 - UISegmentedControl to display different view controllers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM