Objective-c – illegal configuration – Static table view are only valid when embedded in UITableViewController

ios5iphoneobjective cstoryboard

I have create a scene using the story board that contains a single, grouped table view. The cells for this table are static (this is a configuration view). I created all the table cells from within the storyboard editor The view is assigned a custom view controller which inherits from the UITableViewController. If set this as the 'initial view controller' for testing purposes the application crashes. The error is:

illegal configuration – Static table view are only valid when embedded in UITableViewController

In the view controller for this view i have implemented both tableView:numberOfRowsInSection & numberOfSectionsInTableView

Can someone tell me how to make static tableviews work with storyboards?

Thanks!

Best Answer

By default when Xcode creates a subclass of UITableViewController it adds UITableView datasource delegate methods. Since a static TableView does need a datasource these NEED to be removed.

So the solution was to remove these delegate methods:

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Related Topic