Menu bar set up

Hi everyone I need some help with setting up as well as figuring out what I need to do to make the menu bar work. For the menu bar I’ve created the different options a viewer will have on the menu bar itself (as a button in a table view cell). I have created a tableview controller for the menu bar as well. But When I run the simulator and try to click on one of the menu options I get this issue.

we might need more information but it seems that your menubar has not been referenced or linked correctly to your viewcontroller

1 Like

what information would you need?

Can you show the actual code that this is about, creating the menu bar

Please post it as text, not a screenshot. You can do this by placing three backticks on the line before your code and three backticks on the line after your code so that it will be formatted properly. You can also highlight an entire code block and click the </> button on the toolbar to wrap the block for you.

This makes it far easier to read and also makes it easier for other posters to copy/paste the code in order to test solutions and such.

import UIKit

class MenuBarTableViewController: UITableViewController {

    @IBOutlet weak var myLists: UITableViewCell!
    
    @IBOutlet weak var discoverByHealth: UITableViewCell!
     
    @IBOutlet weak var discoverByVeggie: UITableViewCell!
     
    @IBOutlet weak var discoverByFruit: UITableViewCell!
     
    @IBOutlet weak var discoverByOther: UITableViewCell!
     
    @IBOutlet weak var recipes: UITableViewCell!
    
    @IBOutlet weak var contactUs: UITableViewCell!
     
    @IBOutlet weak var searchBar: UISearchBar!
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
  
    }
    
    
    
      
    // MARK: - Table view data source

func numberOfSections(in tableView: UITableView) -> Int {
        // #warning Incomplete implementation, return the number of sections
        return 1
    }

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        // #warning Incomplete implementation, return the number of rows
        return 7
    }

hmm hard to tell… might be just easier to just drop a link to your project so we can look at it…

why did you limit it to 7 rows though?

I just put 7 for now because I had 7 options that is why. What should I change it to?

wait a minute… what is this “menu” bar your are talking about though? it seems like this should just a be a list of buttons instead of being a tableview… something like buttons inside a vertical stackview.

any particular reason why you want to use tableview? i mean its possible but you are going about it the wrong way… for this to work the “items” need to be inside an array so something like

menu = [“myLists”, “discoverByHealth”, “discoverByVeggie”] something like that… then just proceed to normally populate the tableview cell content using these items

Well technically yes it is a list of buttons. Ok so I shouldn’t do it as a table view and just do it as a regular view controller? Sorry I am still new at this I’m learning as I go along.

depends… like i said it should be fine as a tableview but it might be hard to implement especially for a beginner so try working with buttons for now since its much direct to the point

ok sounds good. I did use buttons within the tableview cells, if that makes a difference