问题
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

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.
回答1:
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?
回答2:
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?
来源:https://stackoverflow.com/questions/13043741/debugging-strategies-when-uitableviews-cells-dont-load