【发布时间】:2015-04-28 19:17:01
【问题描述】:
我正在尝试为我的 iOS 应用创建一个选项页面。我有一系列这样的类别:
var options = [
"Location",
"Calculation Method",
"Juristic Method",
"Manual Adjustment",
"Daylight Saving Time"
]
然后我将它们加载到我的视图控制器中,如下所示:
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return options.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = UITableViewCell(style: .Default, reuseIdentifier: "Cell")
cell.textLabel?.text = options[indexPath.row]
return cell
}
这给了我一个完美的单一表格视图!现在我正在尝试处理每一行的点击以显示该类别的选项列表。例如,Location 将有一个开关来启用 GPS 或允许他们选择他们的位置下拉菜单或地图。 Calculation Method 将显示复选标记的表格视图。 Daylight Saving Time 将打开一个带有开关的单行。
我的问题是这一切的最佳方法是什么?我应该创建一个数组字典来保存我的选项并重用表格,还是应该为每个选项类别创建一个单独的视图?我在这方面发现了相互冲突或过时的教程,而且我在转换来自 Objective-C 的示例时也遇到了麻烦。任何帮助或指导将不胜感激!
【问题讨论】:
标签: ios uitableview swift ios8 tableview