簡體   English   中英

帶有Nav Controller的Xcode Table View Controller不顯示表格單元格,但正在處理來自單元格的數據

[英]Xcode Table View Controller with Nav Controller is not displaying table cells but is processing the data from the cells

我正在使用表視圖和導航控制器為列表設置基本的CRUD操作。 當我在初始“表格視圖”中單擊加號按鈕時,應該使用segue模態顯示下一個“表格視圖”,在其中可以向表格單元格中的文本字段中的列表中添加項目。

現在,當我單擊加號按鈕時,它將帶我到右側頁面,並且導航欄按鈕在該頁面上起作用。 單擊完成后,我在情節提要中輸入的textField中的文本將添加到列表中,因此我知道它在某處。 我已經設置了自動版式,所以這應該不是問題。 似乎有一些東西覆蓋了表格單元格(全部為深灰色),但我不知道這是什么。 請參見下面的圖片進行說明:

此圖顯示了情節提要,最后一個是我遇到的問題

此圖像顯示了應用程序的當前狀態,中間框架應顯示文本字段

第二個視圖的代碼:

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)

}

我仍然不確定發生了什么,但這對我有用:

我在第二個視圖控制器中取消注釋了該默認代碼行,並看到我的表格單元格出現了。 我推薦了它,它仍然有效。

self.navigationItem.rightBarButtonItem = self.editButtonItem()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM