Reputation: 1366
I'm new to Objective-C and trying to create custom cells. In the storyboard (under Xcode 4.2) i am pushing a TableViewController. In this Controller i am Displaying some simple Cells, but now i want to customize them. (In older Versions of Xcode, I was using something like this:
if (cell == nil) {
NSArray * topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"MyNib" owner:nil options:nil];
for(id currentObject in topLevelObjects) {
if([currentObject isKindOfClass: [UITableViewCell class]]) {
cell = (detailViewCell *) currentObject;
break;
}
}
}
to load my custom cells, but now that doesn't work anymore because I am getting an error that the Nibfile "MyNib" wasn't found, sure.. because I'm using storyboard.. but how can I fix that? How can I load a CustomCell from Storyboard?
EDIT: "haha, I'm such an idiot.. solved the problem on my own.
static NSString *CellIdentifier = @"detailsViewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
I thought these lines create a new standard cell with the identifier "detailsViewCell", so I haven't changed that to my custom cell identifier yet, but yeah, instead of that they load my created custom cell. :) now everything works well! "
Upvotes: 4
Views: 3851
Reputation: 7579
you don't need to create from Nib anymore, just call dequeueReusableCellWithIdentifier
and will return u the cell you want. But at first, you'll need to create a new class for your custom cell.
Found a introduction video for u, check this out
Upvotes: 5