ios - How can i use custom UITableViewCell and UITableView in same xib -
i want use custom uitableviewcell uitableview in same xib without creating uitableviewcell class?
as can see bellow set identifier uitableviewcell , used this:
- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { static nsstring *cellidentifier = @"customidentifier"; uitableviewcell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier]; } }
but not working?
add uitableviewcell *customcell property view controller (for example, file showusers.h)...
@property (nonatomic, strong) iboutlet uitableviewcell *customcell;
and connect custom cell in xib. use following code in cellforrow (for example, file showusers.m) :
if (cell == nil) { [[nsbundle mainbundle] loadnibnamed:@"nibname" owner:self options:nil]; cell = self.customcell; self.customcell = nil; }
Comments
Post a Comment