correct way to set up a tableviewcontroller set inside a viewcontroller.

So using the storyboard i have a ViewController and placed a TableView inside of it. I want a UI that shows a list with buttons at the bottom and i think this is the best way so far.

so i have my UIViewController ViewController and then i have a UITableView TableViewController. Everything i have read about filling a table with data runs off ViewDidLoad but that is not in the UITableView.

can someone point me in the right direction of how this should be set up correctly?

Best Answer

  • Daedric1991Daedric1991 AU ✭✭
    Accepted Answer

    @TedRogers said:
    @Daedric1991 If you are using a ViewController with a TableView inside of it you should not be using a UITableViewController so perhaps that is your problem. In your case you need to create an outlet to your TableView so your view controller can access it in ViewDidLoad.

    The output for TableView only gets setup if you derive from UITableViewController and you have a TableViewController in your storyboard/xib.

    If you want to use a UITableViewController so you get automatic things like refresh, you could use a view container in your view controller that contains a separate UITableViewController.

    Ahh sorry, i have a UITableView called that.
    It's only method is this
    public TableViewController (IntPtr handle) : base (handle)
    {
    var tableSource = new TableSource();
    this.Source = tableSource;
    }

    TableSource is a UITableViewSource.

    this seems to work just fine. however after doing all of this i have realized i want a multi-option list anyway.

Answers

  • TedRogersTedRogers USMember ✭✭✭✭

    @Daedric1991 If you are using a ViewController with a TableView inside of it you should not be using a UITableViewController so perhaps that is your problem. In your case you need to create an outlet to your TableView so your view controller can access it in ViewDidLoad.

    The output for TableView only gets setup if you derive from UITableViewController and you have a TableViewController in your storyboard/xib.

    If you want to use a UITableViewController so you get automatic things like refresh, you could use a view container in your view controller that contains a separate UITableViewController.

  • Daedric1991Daedric1991 AUMember ✭✭
    Accepted Answer

    @TedRogers said:
    @Daedric1991 If you are using a ViewController with a TableView inside of it you should not be using a UITableViewController so perhaps that is your problem. In your case you need to create an outlet to your TableView so your view controller can access it in ViewDidLoad.

    The output for TableView only gets setup if you derive from UITableViewController and you have a TableViewController in your storyboard/xib.

    If you want to use a UITableViewController so you get automatic things like refresh, you could use a view container in your view controller that contains a separate UITableViewController.

    Ahh sorry, i have a UITableView called that.
    It's only method is this
    public TableViewController (IntPtr handle) : base (handle)
    {
    var tableSource = new TableSource();
    this.Source = tableSource;
    }

    TableSource is a UITableViewSource.

    this seems to work just fine. however after doing all of this i have realized i want a multi-option list anyway.

Sign In or Register to comment.