Revision: 44729
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at April 16, 2011 13:49 by athanhcong
Initial Code
@implementation UITableViewCell (NibLoader)
#pragma mark Load cell nib
+ (id)loadViewWithNibName:(NSString *)nibName owner:(id)owner class:(Class)class {
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:nibName owner:owner options:nil];
for (id currentObject in topLevelObjects) {
if ([currentObject isKindOfClass:class]) {
return currentObject;
}
}
return nil;
}
+ (UITableViewCell *)loadCellForTableView:(UITableView *)tableView reuseIdentifier:(NSString *)cellIdentifier nibNamed:(NSString *)nibName {
// Load custom cell
// ref link: http://www.e-string.com/content/custom-uitableviewcells-interface-builder
UITableViewCell *itemCell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (itemCell == nil) {
itemCell = [self loadViewWithNibName:nibName owner:self class:[UITableViewCell class]];
}
return itemCell;
}
@end
Initial URL
Initial Description
Initial Title
UITableViewCell+NibLoader
Initial Tags
Initial Language
Objective C