Ios Xcode UIButton到UITableView未连接

Ios Xcode UIButton到UITableView未连接,ios,uitableview,uibutton,Ios,Uitableview,Uibutton,我正在设计一个项目,当单击按钮时,我希望它转到表视图 以下是故事板的图片: 以下是带有按钮的视图的代码: import UIKit import os.log class MealViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate { //MARK: Properties @IBOutlet

我正在设计一个项目,当单击按钮时,我希望它转到表视图

以下是故事板的图片:

以下是带有按钮的视图的代码:

import UIKit
import os.log

class MealViewController: UIViewController, UITextFieldDelegate, UIImagePickerControllerDelegate, UINavigationControllerDelegate {

    //MARK: Properties
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var priceLabel: UILabel!
    @IBOutlet weak var photoImageView: UIImageView!
    @IBOutlet weak var ratingControl: RatingControl!
    @IBOutlet weak var caloriesLabel: UILabel!
    @IBOutlet weak var descriptionLabel: UILabel!


    @IBAction func addToCart(_ sender: UIButton) {
    }
下面是表视图代码:

import UIKit

class CartTableViewController: UITableViewController {

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

    // MARK: - Table view data source

    override func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 0
    }

当我按原样运行它时,它会打开一个空白表。当我更改numberOfRowsInSection时,它会给出一个sigabrt错误。如何让它定期打开视图?

函数numberOfRowsInSection定义给定节中的行数。如果定义0,则表必须为空。如果定义了其他内容,表视图将通过调用以下命令为每行请求一个具体单元格:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
根据您的代码,这是第一个查找崩溃原因的地方。你截取的代码没有显示出来