views:

19

answers:

1

Hi, I've tried looking it up here... but could see more questions like that one, but no answers.

I'm trying to add a new cell at the bottom of my table (add 1 more cell to the end) the cell should be different from the rest of the table cells, so I've created a new NIB with tableCell.

i've used this way to find the last cell in my table:

NSInteger sectionsAmount = [tableView numberOfSections];
NSInteger rowsAmount = [tableView numberOfRowsInSection:[indexPath section]];
if ([indexPath section] == sectionsAmount - 1 && [indexPath row] == rowsAmount - 1)

and inside, i would like to use my new tableCell, so I'm doing as follows:

    static NSString *CustomCellIdentifier = @"InboxLoadMoreCell ";
    InboxLoadMoreCell *cell = (InboxLoadMoreCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];
    if (cell == nil) {
        NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"IphoneLoadMoreCell" owner:self options:nil];
        for (id oneObject in nib)
            if ([oneObject isKindOfClass:[InboxLoadMoreCell class]])
                cell = (InboxLoadMoreCell *)oneObject;
    }

I have two issues now, 1. the new custom tableCell is not being loaded. 2. the row being updated is the last row but not a new row at the end (therefore, 1 needed row is being overridden)

Any Ideas how to proceed with this?

A: 

The way I do this, is set the file owner in interface builder to be a UIViewController. Load the bundle, and set my cell to that view controller's view. i.e.,

UIViewController* c = [[UIViewController alloc] initWithNibNamed:@"IphoneLoadMoreCell" bundle:nil];
cell = (MyCustomCell*)c.view;
[c release];

Just make sure you only do that on your last item, and you should be fine -- assuming you of course, set up your custom cell as I directed in your nib.

jer
Hey, Thanks for the replay.Please try to be more specific, (Maybe step by step description)i'm kinnda new to this, and tried the above but it crashes when i scroll to the last cell.i've changed my customTableViewCell to be UIViewController in the Interface Builder.you wrote cell = (MyCustomCell*)c.view;what should be MyCustomCell ? thanks, Dror.
Dror Sabbag
You have to make sure your File Owner in interface builder is set to the type UIViewController for the above to work. If it is this way, show me the reason for the crash (see your crash report, or the output from the Console when it crashes). I can't break it down anymore than i already have, that is step by step.
jer