【发布时间】:2016-09-11 16:26:29
【问题描述】:
我正在使用表视图和导航控制器为列表设置基本的 CRUD 操作。当我在我的初始表格视图中单击加号按钮时,它应该使用 segue 以模态方式呈现下一个表格视图,我可以在表格单元格中的文本字段中将项目添加到列表中。
就像现在一样,当我单击加号按钮时,它会将我带到正确的页面,并且导航栏按钮在该页面上工作。当我单击完成时,我在情节提要中输入的 textField 中的文本将添加到列表中,因此我知道它在某处。我已经设置了自动布局,所以这不应该是问题。看起来有东西覆盖了表格单元格(全是深灰色),但我不知道它是什么。请参阅下面的图片进行说明:
this image shows the storyboards, the last board is the one I having trouble with
第二个视图的代码:
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