Storyboard error with uitableview

I am getting this error when trying to create my application structure with boards with stories

static table views are only valid when inserted into a UITableViewController instance

I created this sotry pane which has a navigation controller and then multiple views that separate the main view which has a table view in it.

one of the views I made from the main view has this error. I have several other views with the same setup, but none of them have this problem. im woudnering if i resolve this then they say the same thing after this was the first view i created.

any help would be appreciated.

+3


source to share


2 answers


When you say opinion, I am assuming you mean UIViewControllers. For static tables, your view controller must (must be) a UITableViewController, which is a subclass of UIViewController that handles tables, in particular static tables in your case.



+3


source


I was able to set a static UITableView inside my UIViewController by simply dragging the UITableView onto my ViewController in IB and attaching both the delegate and the data source to my view controller and then implementing (even if I use a static table, just to close Xcode)

@interface MyController : UIViewController <UITableViewDelegate, UITableViewDataSource>
  @property (strong) IBOutlet UITableView *myTableView;
@end

      



If you want to host multiple UITableViews inside your ViewController with IB, you can create separate files / classes for each UITableView and then wire them up as delegates. I see a bunch of answers that insist that you should subclass from UITableViewController and you don't.

@interface MyTableViewDelegate : NSObject <UITableViewDataSource, UITableViewDelegate, UIScrollViewDelegate>

      

+5


source







All Articles