ios - Is there any way to use prototype cells in UIViewController other than UITableViewController? -
i made tableview subview of uiviewcontroller , , in storyboard , add prototype cells scene . seems design of cells in storyboard not working , seems prototype cells works uitableviewcontroller?
here storyboard design use tableview viewcontroller's subview , , add 2 prototype cells in (pink , blue cell) 
and here tableview codes:
@implementation subviewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view. [self.tableview registerclass:[tableviewcell class] forcellreuseidentifier:@"tableviewcell"]; [self.tableview registerclass:[atableviewcell class] forcellreuseidentifier:@"atableviewcell"]; } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } /* #pragma mark - navigation // in storyboard-based application, want little preparation before navigation - (void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender { // new view controller using [segue destinationviewcontroller]. // pass selected object new view controller. } */ - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section { return 2; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview { return 1; } - (uitableviewcell*)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath { if (indexpath.row == 0) { tableviewcell* cell = [tableview dequeuereusablecellwithidentifier:@"tableviewcell" forindexpath:indexpath]; return cell; } else { atableviewcell* cell = [tableview dequeuereusablecellwithidentifier:@"atableviewcell" forindexpath:indexpath]; return cell; } } and when run code ,i expect there blue , pink cell , in fact , tableview got 2 blank cell (seems design in storyboard not working) 
if designing storyboard,you dont need below lines
[self.tableview registerclass:[tableviewcell class] forcellreuseidentifier:@"tableviewcell"]; [self.tableview registerclass:[atableviewcell class] forcellreuseidentifier:@"atableviewcell"]; instead of need set identifier cell in storyboard in below image

Comments
Post a Comment