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) enter image description here

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) enter image description here

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

enter image description here


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -