ios - Approaches to implement tapped inserting table cell with radio buttons -


what i'm trying insert new data data source array, , [tableview reloaddata]. new array can inserted, there 2 problems.

1) want have 2 radio buttons in new cell users choose. should define new cell object or something?

2) when reloading data, selected cell's color cannot set green before.

or other suggestions on how best implement this, thanks!!: enter image description here

for first problem, pre-layout cell containing 2 radio buttons either in storyboard (you can in .xib file). set identifier "languageskillselectiontableviewcell" or something. after that, when load new set of data table view can manage presentation of cells in table view through callback cellforrowatindexpath:

an example if want load languageskillselectiontableviewcell @ beginning, set @ indexpath.row == 0. else set contents of data list other rows.

- (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *tablecell;      if(_loadednewdata)     {         if(indexpath.row < datalist.count && indexpath.row > 0)         {             tablecell = (datatableviewcell *)[tableview dequeuereusablecellwithidentifier:@"datatableviewcell"];              //set attributes of tablecell         }          else         {             tablecell = (languageskillselectiontablviewcell *)[tableview dequeuereusablecellwithidentifier:@"languageskillselectiontableviewcell"];              //set attributes of tablecell         }     }      else     {         //load in default order     }      return tablecell; } 

you can play arrangement , presentation of cells under callback.

for second problem, have store flag or state selection picked user in global variable within class. everytime cells reloaded can update selection state of cell setting method cell update selection state of radio button.

for example:

if user selected english, like:

 - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     uitableviewcell *tablecell;      if(_loadednewdata)     {         if(indexpath.row < datalist.count && indexpath.row > 0)         {             tablecell = (datatableviewcell *)[tableview dequeuereusablecellwithidentifier:@"datatableviewcell"];              //set attributes of tablecell         }          else         {             tablecell = (languageskillselectiontablviewcell *)[tableview dequeuereusablecellwithidentifier:@"languageskillselectiontableviewcell"];              //set attributes of tablecell              [(languageskillselectiontablviewcell *)tablecell setlanguageselectionstate:canreadwrite];         }     }      else     {         //load in default order     }      return tablecell; } 

Comments

Popular posts from this blog

sql server - Cannot query correctly (MSSQL - PHP - JSON) -

php - trouble displaying mysqli database results in correct order -

C++ Linked List -