erenkabakci erenkabakci - 1 year ago 83
Objective-C Question

No Visible View in Custom Table View Cell

I am doing an exercise about

. And I am having some problems with custom view cells.

I have created my own custom
with .xib file called as
. I have required .h and .m files and I choose super class as

In my view controller called as
I was creating a table with default cells like this.

- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];

cell.textLabel.text = [showNames objectAtIndex:[indexPath row]];
cell.imageView.image = [UIImage imageNamed:[iconArray objectAtIndex:[indexPath row]]];

return cell;

Once I have created my own custom view. I imported
into my
and I updated the code like this.

- (UITableViewCell *)tableView: (UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath

static NSString *newCellViewString = @"newCellView";

newCellView *cell = [tableView dequeueReusableCellWithIdentifier:newCellViewString];

//newCellView *cell = [[newCellView alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:newCellView];
if (cell == nil)
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"newCellView" owner:self options:nil];
cell = (newCellView *)[nib objectAtIndex:0];

But when I run the app I see a blank page, like I have no related view. Maybe I forgot some connections to add. I can't even see empty cells to view. Only a white blank page. Any help would be great. Thanks.


Here are my .h and .m files.

#import <UIKit/UIKit.h>

@interface newCellView : UITableViewCell <UITableViewDelegate>

@property (nonatomic, strong) IBOutlet UILabel *nameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *iconImageView;
@property (retain, nonatomic) IBOutlet UIButton *extendButton;


.m file

#import "newCellView.h"

@implementation newCellView

@synthesize nameLabel;
@synthesize extendButton;
@synthesize iconImageView;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
return self;

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
[super setSelected:selected animated:animated];

// Configure the view for the selected state

- (void)dealloc {
[extendButton release];
[nameLabel release];
[iconImageView release];
[super dealloc];

Answer Source

I found the answer. Everything was working good in my code except the positioning of the cell view's.

Project was using autolayout as a default property. So whenever i see the white page actually cells were out of bounds. I disabled autolayout and set movement properties of the items from size inspector.

Thanks for efforts.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download