[英]How to open up a new tableview programmatically in swift
I created a tableview in storyboard that contains 11 rows. 我在情节提要中创建了一个包含11行的表格视图。 I want to be able to tap on each row and have it open up into it's own tableview controller, where I will store data, depending on the row tapped.
我希望能够点击每一行并将其打开到自己的tableview控制器中,根据所点击的行,我将在其中存储数据。
var array = ["row 1", "row 2", "row 3", "row 4", "row 5", "row 6", "row 7", "row 8", "row 9", "row 10", "row 11"]
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return array.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("prototypeCellIdentifier", forIndexPath: indexPath)
cell.textLabel?.text = array[indexPath.item]
cell.accessoryType = UITableViewCellAccessoryType.DisclosureIndicator
return cell
}
This is what I have done to create the rows. 这就是我创建行所要做的。
In short: 简而言之:
show
show
To send data to the ViewController that's been shown by clicking a row, you should look into the method prepareForSegue(_)
要将数据发送到单击行已显示的ViewController,应查看方法
prepareForSegue(_)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.