ios - Multiple UIPickerView in the one TableViewController Programatically -


i've been trying several days can't find way works. ways i've tried set loads pickerviews keyboards textfields want doesn't show of data i've put them. can me through setps of or give me link , example of it. thank helper.

    uitoolbar *toolbar = [[uitoolbar alloc] init];     [toolbar setbarstyle:uibarstyleblack];     [toolbar setbartintcolor:[uicolor colorwithred:237.0/255.0 green:30.0/255.0 blue:36.0/255.0 alpha:1.0]];     [toolbar sizetofit];     uibarbuttonitem *flexbutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemflexiblespace target:self action:nil];     uibarbuttonitem *donebutton =[[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemdone target:self action:@selector(resignkeyboard)];      donebutton.tintcolor = [uicolor whitecolor];      nsarray *itemsarray = [nsarray arraywithobjects:flexbutton, donebutton, nil];     [toolbar setitems:itemsarray];      yourtextfield.inputaccessoryview = toolbar;     uipickerview *categorypicker   = [[uipickerview alloc] initwithframe:cgrectmake(0, 210, 320, 216)];     categorypicker.backgroundcolor = [uicolor whitecolor];     categorypicker.delegate = self;     categorypicker.datasource = self;     categorypicker.tag = 1;     yourtextfield.inputview  = categorypicker; 

after writing code in viewdidappear, implement delegate , datasource of pickerview

pragma mark -uipickerview delegate , datasource

- (nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview {     return  1; }  - (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component {     return  yourdatasource.count; }  - (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component {     return [yourdatasource objectatindex:row]; }  - (void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component {     yourtextfield.text = [yourdatasource objectatindex:row]; } 

and implement selector done button that

- (void)resignkeyboard {     [bloodgroupfield resignfirstresponder]; } 

Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -