Domanda

I have updated my app and added some features but something weird is happening with my tableviews. Let me explain:

I have a tableview, and when a row is pressed I want to open a new view controller.

I am using storyboard and segues and here is what I have:

Storyboard and a segue that when the row is pressed opens the view controller.

Content of each row is in a separate .xib file (If left the same I got a force close in IOS 6.0 or I could handle the content, no matter what I added).

So my EachCell.xib is this: EachCell.xib

This is my code for each cell:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier=@"EachCell";
    //this is the identifier of the custom cell
    EachCell *cell = (EachCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

    tableView.backgroundColor=[UIColor clearColor];
    tableView.opaque=NO;
    tableView.backgroundView=nil;

    if (cell == nil)
    {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"EachCell" owner:self options:nil]; ######HERE IS THE SIGBART PROBLEM
        cell = [nib objectAtIndex:0];
    }
   /*** bla bla bla**/


    return cell;
}

and this is for pressing and open the new view controller:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
/..rest of code ../
[self performSegueWithIdentifier:@"nameofsegue" sender:tableView];
        }

I have mentioned where the SIGBART problem is.

EachCell is the name of the .h,.m,.xib file and the reuse identifier of my custom cell. I have only inserted the tablecell in the storyboard so that I can set my segue.

Weird thing is that it plays in IOS 6.0 but not in IOS 5.1.

That's the error I get in ios5.1:

NSInternalInconsistencyException, the Nib data is invalid.
È stato utile?

Soluzione

It sounds like autolayout is enabled on your custom cell Xib file. Inside the nib make sure the autolayout box is unchecked in its attributes. By default this box is checked. Autolayout is an iOS6 feature so you may need to tweak that cell's layout

enter image description here

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top