【发布时间】:2014-12-12 13:00:10
【问题描述】:
我写的是:
func initializeMyDictionary() {
self.example = [MyDictionary(name: "Some Name", text: "some text", link: "linkToSomeDocument"),
MyDictionary(name: "Second Name", text: "some text", link: "secondLink")]
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let identifier: String = "tableCell"
var cell: TableCell! = tableView.dequeueReusableCellWithIdentifier(identifier) as? TableCell
if cell == nil {
cell = TableCell(style: UITableViewCellStyle.Value1, reuseIdentifier: identifier)
}
cell!.nameLabel!.text = example[indexPath.row].name
return cell!
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return example.count
}
然后将它链接到 Main.storyboard 上的 DetailViewController(我创建的)。每个 myDictionary 字符串的 DetailView 都显示在我的 tableView 中。一切正常。
但我想从 MyDictionary(链接)中显示一些行的第二个值。 1 行显示 MyDictionary 中的“名称”和“文本”,2 行显示“链接”中的文档或 URL。这是不可能的还是如何做这样的事情?
我很抱歉我的无知和糟糕的英语。
【问题讨论】:
-
尝试使用
UITableViewCellStyle.Subtitle而不是UITableViewCellStyle.Value1并通过cell!.textLabel!.text = example[indexPath.row].name访问名称标签和cell!.detailTextLabel!.text = example[indexPath.row].link这样的字幕标签希望这是你想要的 -
@anneblue 感谢您的回答,但我想从单元格中打开不同的 DetailView,以便在此单元格中使用不同的内容。例如:#1、#2、#3、#4 和 #6 单元格打开了我创建的 DetailViewController(这对我来说没有任何问题);单元格#5 我想打开绑定到它的 RTF 文档。但我的问题如下:每个单元格都打开 DetailViewController,但我无法将其中一个单元格设为单独的。
标签: ios uitableview swift tableview tablecell