我对 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/