Ollie177
Ollie177

Reputation: 315

Getting an error that I don't recognise when creating a custom UITableViewCell?

I've created a custom UITableViewCell in my project and I've made it using a .xib file here is a couple of images of the set up:

Background, selected, and main Cell view

enter image description here

This is an image of my main cell, selected, and background for said cell. This is the link up for the Main Cell.

So as far I am aware this part works fine.

this is the error I'm getting: Error message

I thought it was because I was trying to load the cell before the tableview? but my table view loads when the rootViewController does so that can't be it... here is my code for the table view (relevant code):

Key: GroupCell = name of my .h, .m, .xib file of my cell.

objectivenameArray = array with the server data collected with an NSString executed with an NSMutableArray.

- (NSInteger)tableView: (UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{  
    return [objectivenameArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    static NSString *cellID = @"cellID";

    GroupCell *groupCell = [tableView dequeueReusableCellWithIdentifier:cellID];
    if (groupCell == nil) {
        groupCell = [[GroupCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID];
    }

        groupCell.objectiveLabel.text = [objectivenameArray objectAtIndex:indexPath.row];

    return groupCell;
}

I'll add that I'm using the server API AFNetworking but this should be creating an issue as all my URLData is linked up properly. The problem began to occur when I tried to Load the Custom Cell. Any ideas? thanks in advance!

Upvotes: 0

Views: 229

Answers (2)

Ollie177
Ollie177

Reputation: 315

To answer my own question; The error I received was because I still had the Auto layout feature switched on my custom cell .xib file.

Upvotes: 1

hukir
hukir

Reputation: 1743

It looks like the error message is pretty clear.

GroupCell's implementation of -layoutSubviews needs to call super

I assume you have overridden layoutSubviews in GroupCell and you forgot to put [super layoutSubviews] at the beginning of the method. Put that in and the error should go away.

Upvotes: 0

Related Questions