开发者

XIB backed View with Subclassing

I have a UITableViewCell defined in a XIB (with outlets setup) and the custom class set to 'CustomTableViewCell'. I'm now looking to subclass the 'CustomTableViewCell' with a 'SubclassCustomTableViewCell', however I'd like to use the same XIB (and not need to redefine my view. Is this possible? I currently have:

+ (SubclassCustomTableViewCell开发者_如何学编程 *)create
{
    // Create undefined cell.
    id cell = nil;

    // Iterate over NIB and find a matching class.
    NSBundle *bundle = [NSBundle mainBundle];
    NSArray *cells = [bundle loadNibNamed:@"CustomTableViewCell" owner:nil options:nil];
    for (cell in cells) if ([cell isKindOfClass:[self class]]) break;

    // Return cell.
    return cell;
}

But I can't figure out to to get it to return anything but the parent.


+ (SubclassCustomTableViewCell *)create
{
    // Create undefined cell.
    id cell = nil;

    // Iterate over NIB and find a matching class.
    NSBundle *bundle = [NSBundle mainBundle];
    NSArray *cells = [bundle loadNibNamed:@"CustomTableViewCell" owner:nil options:nil];
    for (cell in cells) if ([cell isKindOfClass:[self class]]) return cell; //change this

    // Return cell.
    return nil; //change this
}

could you tell me where + (SubclassCustomTableViewCell *)create is defined, in which class

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜