खोज…


परिचय

लोड कस्टम सेल xib फ़ाइल सेल श्रेणी वर्ग का उपयोग करती है, निब फ़ाइल को पंजीकृत करने की आवश्यकता नहीं है

UITableViewCell की Xib फ़ाइल

UITableView सेल श्रेणी श्रेणी बनाएँ।

UITableViewCell + RRCell.h फ़ाइल

#import <UIKit/UIKit.h>

@interface UITableViewCell (RRCell)

-(id)initWithOwner:(id)owner;

@end

UITableViewCell + RRCell.m फ़ाइल

#import "UITableViewCell+RRCell.h"

@implementation UITableViewCell (RRCell)

#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wobjc-designated-initializers"

-(id)initWithOwner:(id)owner {
    
    if (self = [super init]) {
        
        NSArray *nib = [[NSBundle mainBundle]loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
        self = [nib objectAtIndex:0];
    }
    return self;
}

#pragma clang diagnostic pop



@end

इस विधि का उपयोग करने के लिए सेल श्रेणी वर्ग को सेल में प्रयोग करें। cellForRowAtIndexPath विधि

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    //Creted custom cell xib file to load by cell category class
    CustomCell *cell = [[CustomCell alloc]initWithOwner:self];
    
    return cell;     
}


Modified text is an extract of the original Stack Overflow Documentation
के तहत लाइसेंस प्राप्त है CC BY-SA 3.0
से संबद्ध नहीं है Stack Overflow