【发布时间】:2016-03-20 20:33:34
【问题描述】:
我正在尝试创建我的第一个 iOS 应用,并计划发布到 App Store。这是一个选项卡式应用程序,TableView 嵌入到每个视图控制器中。这是我的一个选项卡式视图控制器的代码:
import Foundation
import UIKit
class AU: UITableViewController {
var textArray = ["001", "002", "003", "004", "005", "006", "007", "008", "009", "010", "011", "012", "013", "014", "015", "016", "017", "018", "019", "020", "021", "022", "023", "024", "025", "026", "027", "028", "029", "030", "031", "032", "033", "034", "035", "036", "037", "038", "039", "040", "041", "042" ]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("AUCell") as UITableViewCell!
cell.textLabel?.text = textArray[indexPath.row]
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return textArray.count
}
}
所以,基本上,当用户点击textArray 中的一项时,我想切换到不同的视图控制器。我目前正在用 Swift 2 编写这个。
【问题讨论】:
标签: ios swift uitableview swift2