简体   繁体   中英

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

I am working on setting up basic CRUD operations for a list using Table Views and Navigation Controllers. When I click the plus button in my initial Table View, it is supposed to use a segue to present modally the next Table View where I can add an item to the list in a text field that is in a table cell.

As it is now, when I click the plus button, it takes me to the right page, and the navbar buttons work on that page. When I click done, the text I have in my textField that I entered in the storyboard gets added to the list so I know it's there somewhere. I have auto layout set up so that shouldn't be the problem. It looks like there is something covering the table cell up (all darker grey), but I can't figure out what it is. See images below for clarification:

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

Code for second view:

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.
}

Protocols in second file:

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

}

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

}

I am still not sure what was going on but this worked for me:

I uncommented this default line of code in my second view controller, and saw that my table cell appeared. I recommented it out, and it still works.

self.navigationItem.rightBarButtonItem = self.editButtonItem()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM