【问题标题】:Xcode Table View Controller with Nav Controller is not displaying table cells but is processing the data from the cellsXcode Table View Controller with Nav Controller 不显示表格单元格,而是处理单元格中的数据
【发布时间】:2016-09-11 16:26:29
【问题描述】:

我正在使用表视图和导航控制器为列表设置基本的 CRUD 操作。当我在我的初始表格视图中单击加号按钮时,它应该使用 segue 以模态方式呈现下一个表格视图,我可以在表格单元格中的文本字段中将项目添加到列表中。

就像现在一样,当我单击加号按钮时,它会将我带到正确的页面,并且导航栏按钮在该页面上工作。当我单击完成时,我在情节提要中输入的 textField 中的文本将添加到列表中,因此我知道它在某处。我已经设置了自动布局,所以这不应该是问题。看起来有东西覆盖了表格单元格(全是深灰色),但我不知道它是什么。请参阅下面的图片进行说明:

this image shows the storyboards, the last board is the one I having trouble with

this images shows the progression of the app as it is now, the middle frame should be showing the text field

第二个视图的代码:

class MissionDetailsTableViewController: UITableViewController {
@IBAction func cancelBarButtonPressed(sender: UIBarButtonItem) {
    cancelButtonDelegate?.cancelButtonPressedFrom(self)
}

@IBAction func doneBarButtonPressed(sender: UIBarButtonItem) {
    delegate?.missionDetailsViewController(self, didFinishAddingMission: newMissionTextField.text!)
}

@IBOutlet weak var newMissionTextField: UITextField!
weak var cancelButtonDelegate: CancelButtonDelegate?
weak var delegate: MissionDetailsViewControllerDelegate?
override func viewDidLoad() {
    super.viewDidLoad()
    // Uncomment the following line to preserve selection between presentations
    // self.clearsSelectionOnViewWillAppear = false

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}

第二个文件中的协议:

protocol CancelButtonDelegate: class {
func cancelButtonPressedFrom(controller: UIViewController)

}

protocol MissionDetailsViewControllerDelegate: class {
func missionDetailsViewController(controller: MissionDetailsTableViewController, didFinishAddingMission mission: String)

}

【问题讨论】:

  • 显示第二个 tableView 的代码

标签: ios swift xcode uitableview uinavigationcontroller


【解决方案1】:

我仍然不确定发生了什么,但这对我有用:

我在第二个视图控制器中取消了此默认代码行的注释,并看到我的表格单元格出现了。我推荐了它,它仍然有效。

self.navigationItem.rightBarButtonItem = self.editButtonItem()

【讨论】:

    猜你喜欢
    • 2015-04-26
    • 2023-03-09
    • 2014-03-12
    • 1970-01-01
    • 1970-01-01
    • 2016-05-07
    • 1970-01-01
    • 1970-01-01
    • 2020-09-30
    相关资源
    最近更新 更多