ios - Can I click tableview cell show picker? -


i establish tableview , want click direct cell show picker select.

then selected value show in cell label component.

but had try labelname.text = picker. or call picker in didselectrowatindexpath . it's not showing picker.

my code below

    -(uitableviewcell*) tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath     {         static nsstring *cellidentifier = @"motdetetableviewcell";         cell = (motdetetableviewcell*)[tableview  dequeuereusablecellwithidentifier:cellidentifier];          if( cell == nil )         {             cell = [[motdetetableviewcell alloc] initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];          }         cell.mottabletitlelabel.text = [tabledatasary  objectatindex:indexpath.row];          if( indexpath.row == 0)         {        }         else if ( indexpath.row == 1)         {             mylb = [ [uilabel alloc ] initwithframe:cgrectmake(_mottableview.frame.size.width -50 , 0.0, 70.0, 40.0) ];                   // -------  expect click picker value show in mylb label             mylb.text = @"picker show value";               [cell addsubview:mylb];          }            return cell;     }       - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath{      switch (indexpath.row) {               case 0:                 break;              case 1:                  // -------- had try put settingpickeproperty in here or viewdidload                 [self settingpickeproperty];                  break;           default:                 break;         }     }      #pragma mark -  settting picker datas     -(void) settingpickeproperty     {         picker = [[uipickerview alloc] initwithframe:cgrectzero];          picker  .delegate = self;         picker  .datasource = self;         [ picker  setshowsselectionindicator:yes];          // -------if use textfield picker had correct show. want click        cell show picker, don't know how set  xxxx = picker;         _pickertf.inputview =  picker  ;          uitoolbar*  mypickertoolbar = [[uitoolbar alloc] initwithframe:cgrectmake(0, 0, 320, 56)];         mypickertoolbar.barstyle = uibarstyledefault;         [mypickertoolbar sizetofit];          nsmutablearray *baritems = [[nsmutablearray alloc] init];          uibarbuttonitem *flexspace = [[uibarbuttonitem alloc]         initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:self action:nil];        [baritems addobject:flexspace];          uibarbuttonitem *donebtn = [[uibarbuttonitem alloc] initwithtitle:@"done" style:uibarbuttonitemstylebordered target:self action:@selector(pickerdoneclicked)];           [baritems addobject:donebtn];         [mypickertoolbar setitems:baritems animated:yes];         // ------ if use textfield had correct...         _pickertf.inputaccessoryview = mypickertoolbar;      }       -(void)pickerdoneclicked     {         nslog(@"done clicked");      }      - (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview     {         return 1;     }       - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:        (nsinteger)component     {         return [titleary count];     }       - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component     {         return [titleary objectatindex:row];     }       - (void) pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component     {      } 

it's code offer every reference.

how achieve click tableview cell show picker select picker value show in mylb?

you not adding pickerview anywhere.

if want add in current view, use

picker = [[uipickerview alloc] initwithframe:cgrectzero];  picker.delegate = self; picker.datasource = self; [picker setshowsselectionindicator:yes]; [self.view addsubview:picker]; 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -