ios - 在 swift 中,如何在原型(prototype)单元格中将行(上面有按钮)推送到不同的 View Controller ?

标签 ios swift tableview

我对 swift 和 Xcode 还很陌生,但对其他面向对象的语言非常熟悉。

Here is my code to display three rows.

override func numberOfSectionsInTableView(tableView: UlTableView) —> Int { 
    // #warning Incomplete implementation, return the number of sections 
    return 1 
} 
override func tableView(tableView: UlTableView, numberOfRowslnSection section: Int) —> Int { 
    // #warning Incomplete implementation, return the number of rows 
    return verseData.count 
} 
override func tableView(tableView: UlTableView, cellForRowAtlndexPath indexPath: NSlndexPath) 
    —> UITableViewCell { 
        let cellOne = tableView.dequeueReusableCellWithIdentifier("VerseOneCell", forindexPath: indexPath) 
        let verseOne = verseData[indexPath.row] cellOne.textLabel?.text = verseOne.type 
        return cellOne 

This是显示的内容。这三个主题中的每一个都有按钮,但我希​​望每个主题都有自己的 View Controller 。我在 Storyboard上设置了三个独立的 View Controller ,但是当我运行它时,按下每个主题都会转到同一个 View Controller 。

最佳答案

在我看来,您只是希望能够选择该行(即不需要按钮)。

你可以

  • 按住 Ctrl 从单元格拖动到 Storyboard中的新 View Controller ,并在 prepareForSegue 中配置您的 View Controller

  • 实现 didSelectRowAtIndexPath,您可以在其中检查 indexPath.row 以检查选择了哪一行。

关于ios - 在 swift 中,如何在原型(prototype)单元格中将行(上面有按钮)推送到不同的 View Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33836528/

相关文章:

ios - 如果我创建一个新窗口并 makeKeyAndVisible,前一个窗口会发生什么

android - Android 和 iOS 在 Intent 和后台操作方面的差异

ios - 如何在 UITextView 中插入商标符号 (TM)?

arrays - 编译 Swift 源文件在大型数组reduce-combine + 表达式上挂起

ios - "Value of type ' (CGRect) -> CGRect' has no member 'height' "是什么意思?

java - 将整数(非字符串)数据插入 JavaFX2 TableView

JavaFX 和 TableView - 首次选择不起作用

javascript - 为什么此页面与移动浏览器不兼容?

ios - addArrangedSubview 是重叠 View

c++ - 从 TableView 中选择行时,将 int 值分配给组合框