Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9183389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T18:47:25+00:00 2026-06-17T18:47:25+00:00

Solution: The solution was to start by properly starting with a UITableView and then

  • 0

Solution:

The solution was to start by properly starting with a UITableView and then adding the UITableView delegates to the UIViewController as outlined in the selected answer.

Preface: I have read nearly every article on the matter and nothing advised has helped.

I’m embedding a UITableViewController’s UITableView into a UIViewController.

I understand that nothing will be called unless the view is rendered, so I render it and I can use NSLog to show that it hit those methods.

I tried making a UITableViewController in InterfaceBuilder and setting my subclass as its custom class which worked!! But that’s not how I need to go about it. Here’s what I’ve gathered / done:

  • I am using InterfaceBuilder to manage the UIViewController but I’m adding the UITableView programmatically
  • Both the delegate and dataSource are set properly and self.tableView is not nil
  • Despite the valid logging, cellForRowAtIndexPath is never called and the rendered UITableView is blank
  • I added the delegates to my controller which did not change anything

I have set the following on the UITableViewController:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSLog(@"%@", self.questions); // This outputs the questions array as not empty and works
    // As you can see I am also returning 1.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"%d", [self.questions count]); // This outputs 4 as it should
    return [self.questions count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    // All we need to focus on is this NSLog which never outputs
    NSLog(@"Was called and array is, %@" self.questions);

    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    return cell;
}

I’ve tried setting the view many ways: Adding UITableViewController directly, adding the UITableViewController’s UITableView (which seems to be the correct way), but nothing is working.

Perhaps there is a major step I have forgotten when when working with InterfaceBuilder or some random thing I have forgotten. Any help would be appreciated. Thanks!

** UPDATE **
Here is how I add either the UiTableViewController or the UITavleView

GTTableViewController *tvc = [[GTTableViewController alloc] initWithStyle:UITableViewStylePlain];
// Either
[self.view addSubview:tvc.view];
// OR
[self.view addSubview:tvc.tableView];
// Just to make sure everything is still ok.. and I see the 2/3 TV methods fire.
[self.tableView reloadData];
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T18:47:26+00:00Added an answer on June 17, 2026 at 6:47 pm

    Instead of trying to analyze your code, I will show you a simple example how to programmatically add a table view to a view controller that is not a UITableViewController. Hopefully this will help you getting your problem ironed out by yourself.

    In the .h file:

    @interface MyViewController : UIViewController <UITableViewDelegate, UITableViewDataSource>
    {
    }
    @end
    

    In the .m file:

    - (void) loadView
    {
      CGRect mainViewFrame = CGRectMake(...);
      self.view = [[[UIView alloc] initWithFrame:mainViewFrame] autorelease];
    
      // You could make this even simpler if you set the table view as
      // your main view
      CGRect tableViewFrame = self.view.bounds;
      UITableView* tableView = [[[UITableView alloc] initWithFrame:tableViewFrame style:UITableViewStylePlain] autorelease];
      [self.view addSubview:tableView];
    
      tableView.delegate = self;
      tableView.dataSource = self;
    }
    

    That’s pretty much it. Nothing spectacular, but with this simple setup the UITableViewDataSource data source methods should be happily triggering, including tableView:cellForRowAtIndexPath:. At least they do here…

    I suggest you take this example and make it work in your environment. Then you slowly rework it step-by-step into the design you want. At some point things will stop working, then you will have the source of your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need a solution to properly stop the thread in Java. I have IndexProcessor
As they do with Sharpdevelop, when you start the solution in debug mode, it
I've tried '--kiosk', '--start-maximized'; but all not work, any solution yet? Further, the web
Solution: API 11 is needed see answer below! Easy Question: After downloading a File
Solution: Make sure nothing is null! I have a ListView throwing a NullPointerException, and
Solution: if you have the same problem, addElement() instead of addChild() is what did
I have a C++ solution in VS2008 with multiple projects. This solution contains files
I have two ASP.NET projects in my solution, and run on different localhost ports
I want to have a plugin that can start my local process, is there
I am writing a service using wcf. I have created a solution with two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.