TableView和Collection视图布局在同一个视图控制器中

时间:2016-12-06 05:57:32

标签: ios swift uitableview layout uicollectionview

我有两个import { Component, ElementRef, ViewEncapsulation } from '@angular/core'; import * as d3 from 'd3'; @Component({ selector: 'simple-bar-chart', template: require('./about.component.html'), styles: [require('./about.component.css').toString()] }) export class AboutComponent { constructor(public elementRef: ElementRef) { } ngOnInit() { var y = d3.scale.linear() .domain([0, 1]) .range([height, 0]); var xAxis = d3.svg.axis() .scale(x0) .orient("bottom"); ,当我点击第一个ERROR in ./angular2App/app/components/about/about.component.ts (34,21): error TS2339: Property 'scale' does not exist on type 'typeof "App_path/node_modules/@types/d3/index"'. ERROR in ./angular2App/app/components/about/about.component.ts (44,24): error TS2339: Property 'svg' does not exist on type 'typeof "App_path/node_modules/@types/d3/index"'. 的按钮时,应该打开tableView(第二个UIViewController),当我点击第一个UIViewControllers的另一个按钮时集合视图(第二个UIViewController)应该打开。

我的意思是当Table View打开时,Collection视图将被隐藏,反之亦然,我想在一个View控制器中 在图像中,您可以看到TableView打开了图像,但是当我点击第一个单元格时,集合视图应该以相同的布局打开。我的意思是它必须显示为这样。

我是UI的新手。 那么我该如何实现UI。

感谢。

enter image description here

1 个答案:

答案 0 :(得分:0)

感谢您提出问题。

我假设你是这样做的:

首先将一个名为:flagIsShowTableView的全局Bool变量放入

当你点击buttonTable for table:

时,现在在你的FirstViewController上

你必须设置Bool:flagIsShowTableView = true

现在点击buttonCollection:

你必须设置Bool:flagIsShowTableView = false

现在在SecondViewController上:

ViewWillAppear中的

:您必须以这种方式进行管理:

if(flagIsShowTableView) {
  tblView.hidden = false
  colView.hidden = true
} else {
  colView.hidden = false
  tblView.hidden = true
}

我确信您已设置并管理所有委托和数据源方法。

相关问题