how to load data to picker view inside custom tableview cell in ios, objective c -


i have table view , few custom cells.in 1 custom cell there picker view.i need load data picker view @ cellforrowatindexpath

this cellforrowatindexpath method

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     nsstring *cellidentifierone = @"detailcell";     flightusertableviewcell *detailcell = [tableview dequeuereusablecellwithidentifier:cellidentifierone];      nsstring *cellidentifiertwo = @"detailcelltwo";     flightusersecondtableviewcell *detailcelltwo = [tableview dequeuereusablecellwithidentifier:cellidentifiertwo];      if (indexpath.section == 0) {          if (indexpath.row ==0) {              //detailcell.titlepickerview **here want load data **              return detailcell;         }         return detailcelltwo;     }        return detailcelltwo; } 

how can that.i know if load data picker view have implement it's delegate methods below.

- (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview {     return 1; }  - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component {     return [cabinarray count]; }  - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component {     return [cabinarray objectatindex:row]; } 

so how can picker view inside custom cell.hope help.

as answers, have implemented delegate methods inside custome tableview cell this

- (void)awakefromnib {     // initialization code }  - (void)setselected:(bool)selected animated:(bool)animated {     [super setselected:selected animated:animated];      // configure view selected state }  - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview {     return 1; }  - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component {      return [leadandadulttitle count]; }  - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component {     return [leadandadulttitle objectatindex:row]; } 

then inside cellforrowatindexpath have implemented this.

 if (indexpath.section == 0) {          nsstring *cellidentifierone = @"detailcell";         flightusertableviewcell *detailcell = [tableview dequeuereusablecellwithidentifier:cellidentifierone];          if (indexpath.row ==0) {              if([traveller isequaltostring:@"lead"])             {                  detailcell.leadandadulttitle = leadandadulttitle;                 detailcell.titlepickerview.delegate = self;                 detailcell.titlepickerview.datasource = self;             }             else             {                detailcell.leadandadulttitle = childandinfanttitle;             }                return detailcell;         } 

note :i tried setting delegate , datasource above , tried dragging pickerview , selecte delegate , datasource

numberofcomponentsinpickerview:]: unrecognized selector sent instance gives

implement picker delegate protocol in custom cell , set data want picker display on cellforrowatindexpath:

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {   nsstring *cellidentifierone = @"detailcell";   flightusertableviewcell *detailcell = [tableview dequeuereusablecellwithidentifier:cellidentifierone];    nsstring *cellidentifiertwo = @"detailcelltwo";   flightusersecondtableviewcell *detailcelltwo = [tableview dequeuereusablecellwithidentifier:cellidentifiertwo];    if (indexpath.section == 0) {     if (indexpath.row ==0) {         detailcell.cabinarray = cabinarray         return detailcell;     }     return detailcelltwo;   }    return detailcelltwo; } 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -