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 7537579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T06:53:21+00:00 2026-05-30T06:53:21+00:00

I am trying to create a custom cell for my UITableView. I am using

  • 0

I am trying to create a custom cell for my UITableView. I am using Xcode 4.2 and using the storyboard along with ARC.

I have created a class to represent the custom cell like so:

ResultsCustomCell.h

#import <UIKit/UIKit.h>

@interface ResultsCustomCell : UITableViewCell
{
    IBOutlet UILabel *customLabel;
}

@property (nonatomic, retain) IBOutlet UILabel* customLabel;

@end

ResultsCustomCell.m

#import "ResultsCustomCell.h"

@implementation ResultsCustomCell

@synthesize customLabel;

@end

I have then implemented the UITableView method in my view controller as follows:
ViewController.m

#import "ViewController.h"
#import "ResultsCustomCell.h"

@implementation ViewController

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad
{
    [super viewDidLoad];
}

// Set the number of items in the tableview to match the array count
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{   
    return 5;
}

// Populate TableView cells with contents of array.
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"CellIdentifier";

    ResultsCustomCell *myCell = [tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"];
    myCell.customLabel.text = @"helloWorld";

    return myCell;
}

// Define height for cell.
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 80;
}

@end

The application builds successfully but then crashes instantly and give me the following error:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'

What part am I missing out?

  • 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-05-30T06:53:23+00:00Added an answer on May 30, 2026 at 6:53 am

    I’m not entirely sure what I have done to resolve my problem but It is now working correctly.

    Here is what I currently have in my ViewController.m

    Note: The ResultsCustomCell.h and .m are the same as above.

    #import "ViewController.h"
    #import "ResultsCustomCell.h"
    
    @implementation ViewController
    
    - (void)didReceiveMemoryWarning
    {
        [super didReceiveMemoryWarning];
        // Release any cached data, images, etc that aren't in use.
    }
    
    #pragma mark - View lifecycle
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];   
    }
    
    // Set the number of items in the tableview to match the array count
    -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {   
        return 5;
    }
    
    // Populate TableView cells with contents of array.
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"CellIdentifier";
    
        // Make sure there are no quotations (") around the cell Identifier.
        ResultsCustomCell *myCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    
        myCell.customLabel.text = @"helloWorld";
    
        return myCell;
    }
    
    // Define height for cell.
    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        return 80;
    }
    
    @end
    

    I then made sure the following things where correct:

    • The table view cell has the correct custom class (ResultsCustomCell).
    • The cell Identifier for the UITableViewCell was correct in Interface Builder.
    • The UILabel in interface builder was correctly linked to the IBOutlet.
    • The UITableView view had the correct controller (ViewController)

    After using this code and checking all of the above it appears to work.

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

Sidebar

Related Questions

I'm trying to create a custom cell for use in a grouped style UITableView
I'm trying to create a custom control - a button - which will have
I'm trying to create a custom UIButton that should look like a UIButtonTypeRoundedRect. In
Im trying to create a custom formatter in Symfony 1.4. I have embedded form
I'm new to Objective-C and trying to create custom cells. In the storyboard (under
I've got a problem trying to create a custom tableview cell for my iPhone
I am trying to create a custom shape class, that is basically a hexagon,
I'm trying to load a single custom cell into a UITableView and it keeps
I'm trying to create a custom table view cell that has a button on
I'm a little confused with something. I'm trying to create a custom cell and

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.