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

  • SEARCH
  • Home
  • 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 8408065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T23:32:24+00:00 2026-06-09T23:32:24+00:00

So I have created a subclass of UITableViewController and set the delegate and datasource

  • 0

So I have created a subclass of UITableViewController and set the delegate and datasource to itself. But still the methods like cellForRowAtIndexPath and numberOfRowsInSection never get called.My numberOfSectionsInTableView return 1 everytime.
This is how viewDidLoad() looks like

- (void)viewDidLoad {
[super viewDidLoad];
NSMutableArray* list = [[NSMutableArray alloc] init];
self.tableView = [[UITableView alloc] init];
self.tableView.delegate = self;
self.tableView.dataSource = self;
self.actionList = list;
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 400.0);
[self.actionList addObject:@"t1"];
[self.actionList addObject:@"t2"];
}

When I try to load this in a popover all I get is a blank popover.
This is what I see in the UIPopover

I have spent a lot of time on this. Please help me out.

EDIT: .m file

// KLActionsViewController.m
#import “KLActionsViewController.h”

@interface KLActionsViewController ()

@end

@implementation KLActionsViewController
@synthesize actionList,delegate;

//- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
//{
//    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
//    if (self) {
//        // Custom initialization
//    }
//    return self;
//}

//- (void)loadView
//{
//    
//}

- (void)viewDidLoad {
    [super viewDidLoad];
    NSMutableArray* list = [[NSMutableArray alloc] init];
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320.0, 100.0) style:UITableViewStyleGrouped];
    self.tableView.delegate = self;
    self.tableView.dataSource = self;
    self.actionList = list;
    self.clearsSelectionOnViewWillAppear = NO;
    self.contentSizeForViewInPopover = CGSizeMake(320.0, 200.0);
    [self.actionList addObject:@"t1"];
    [self.actionList addObject:@"t2"];
    [self.tableView reloadData];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSLog(@"in number of section");
    return 1;
}

- (UITableViewCell *)cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";

    UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
    }
    NSString* lab = [self.actionList objectAtIndex:indexPath.row];
//    NSLog(lab);
    NSLog(@"here in there");
    cell.textLabel.text = lab;
    return cell;
}

- (NSInteger)numberOfRowsInSection:(NSInteger)section
{
    NSLog(@"Total entries : %i ",[self.actionList count]);
    return [self.actionList count];
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.delegate != nil) {
        [self.delegate actionSelected:indexPath.row];
    }
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    self.actionList = nil;
    self.delegate = nil ;
    // Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

@end

The .h file

#import <UIKit/UIKit.h>

@protocol KLActionsViewControllerDelegate
- (void)actionSelected:(NSInteger)index;
@end

@interface KLActionsViewController : UITableViewController <UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, retain) NSMutableArray* actionList;
@property (nonatomic, assign) id<KLActionsViewControllerDelegate> delegate;


@end
  • 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-09T23:32:26+00:00Added an answer on June 9, 2026 at 11:32 pm

    If you are extending the UITableViewController it already creates UITableView instance at viewDidLoad. Try to set a breakpoint there and check it in debugger console:

    po [self view]
    

    Therefore you should not create the UITableView instance by yourself at this point. If you need a custom init of the table view you should do it earlier

    EDIT

    From the documentation:

    About Table Views in iOS-Based Applications

    The easiest and recommended way to create a table view is to create a custom UITableViewController object. UITableViewController creates the table view and assigns itself as delegate and data source.

    Creating a Table View Programmatically

    If you choose not to use UITableViewController for table-view management, you must replicate what this class gives you “for free.”

    - (void)loadView // <-- NOT VIEW DID LOAD!
    {
        UITableView *tableView = [[UITableView alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]
                                      style:UITableViewStylePlain];
        tableView.autoresizingMask = UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
        tableView.delegate = self;
        tableView.dataSource = self;
        [tableView reloadData];
    
        self.view = tableView;
        [tableView release];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a subclass of UITableViewController that is used as the custom class
I have created a subclass of UIView and I would like to have it
I have created a subclass of UIImageView and I am handling the touches for
I have created a custom subclass of UITableViewCell. There, I allow the user to
I have created a subclass of a generic list so that I could implement
I have created a Class (subclass of NSObject) which will hold all my SQLs/dbConnections
Here's the scenario - I have created a custom NSView subclass, and the implementation
I've Created a UITableViewController subclass. Do I only need one controller? Do I just
I have created a subclass of QGLwidget and I was hoping that I could
I have created a custom UIButton (UIButton subclass) for my application. Within this button's

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.