0

I am trying to embed a UITableView into my ViewController's main UIView that is 75% the width of the screen. Ideally this UITableView would also be embedded into a Navigation Controller. Also, it seems I cannot use UIContainerViews with iOS 5 because I encounter the error "Could not instantiate class named UIStoryboardEmbedSegueTemplate" (cf. NSInvalidUnarchiveOperationException with ContainerView).

To do this, I have created a UIView within my ViewController's main UIView that is 75% the width of the screen. Within that UIView I have placed a UINavigationBar and a UITableView. I instantiate the UITableViewController in the ViewController's - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil function. Once instantiated, I connect my ViewController's UITableView to the UITableViewController's UITableView via self.tableViewController.tableView = self.tableView.

Everything seems to work alright, except that my UITableView isn't showing any cells, even if I preload it with data.

What additional data may I provide to help diagnose the problem? I of course don't receive any error message, and the datasource does indeed receive the data and I call [self.tableView reloadData] after the datasource is updated.

UPDATE 1

Chrome for iOS

Ultimately this is the kind of behavior I would like, except that instead of multiple web views I would like multiple table views each embedded in its own navigation controller. I'm guessing that Chrome for iOS just takes a screenshot (?) of the webpage since interaction is not enabled when scrolling through tabs, but how would you do this if you wanted to preserve interaction?

UPDATE 2

The particular line seems to be CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier] where static NSString *CellIdentifier = @"New Cell" (and the appropriate prototype UITableViewCell is defined such in IB). However, the code doesn't seem to crash on this line; instead, a breakpoint seems to be initiated (Thread 1: Breakpoint 1.1) that I did not designate. In addition, this only happens when testing on my iOS device. Everything works fine when testing via the iOS simulator.

Community
  • 1
  • 1
Ken M. Haggerty
  • 24,902
  • 5
  • 28
  • 37

2 Answers2

0

Your datasource methods need to be implemented in your tableViewController (which it seems you did not do). You would have to set the datasource property of your tableViewController to self and implement the methods in your original view controller (i.e. self). Also, you would have to add the <UITableViewDataSource, UITableViewDelegate> protocols in the @interface declaration.

Is it not easier to got the standard route and subclass UITableViewController to override the datasource methods?

Mundi
  • 79,884
  • 17
  • 117
  • 140
  • I've done all of that, except that I delegated my dataSource out to the main ViewController, since I figured that was the active view controller and also the controller receiving relevant touch events, e.g., I've added a plus UIBarButtonItem for adding new entries to the list. Does the dataSource have to be internal? – Ken M. Haggerty Oct 24 '12 at 16:35
  • Should I just copy-past my entire code? StackOverflow doesn't seemed to be designed for doing that (at least well). – Ken M. Haggerty Oct 24 '12 at 16:46
  • Indeed you should not code-dump. Put in break points and log statements - narrow down the problem and post that code. – Mundi Oct 24 '12 at 17:05
0

Hello: The ultimate answer to my particular problem related to how iOS 5 v. iOS 6 handles autolayout, in particular with regard to UITableViewCells ("Autoresize subviews"); cf., What are some reasons why custom UITableViewCells might work in iOS 6 but not iOS 5?

Since this particular question is vague and the "answer" doesn't relate to what I thought the problem was, should I vote to delete it?

Community
  • 1
  • 1
Ken M. Haggerty
  • 24,902
  • 5
  • 28
  • 37