[英]How to open up a new tableview programmatically in swift
我在情節提要中創建了一個包含11行的表格視圖。 我希望能夠點擊每一行並將其打開到自己的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
}
這就是我創建行所要做的。
簡而言之:
show
要將數據發送到單擊行已顯示的ViewController,應查看方法prepareForSegue(_)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.