iPhone fill values for UIPickerView -
i've created uipickerview, displays on button click. question how fill in rowitems
uiactionsheet *actionsheet = [[uiactionsheet alloc] initwithtitle:@"select location" delegate:self cancelbuttontitle:@"cancel" destructivebuttontitle:nil otherbuttontitles:nil]; [actionsheet setactionsheetstyle:uiactionsheetstyleblacktranslucent]; uipickerview *pickerview = [[uipickerview alloc] initwithframe:cgrectmake(0,100,0,0)]; pickerview.showsselectionindicator = yes; pickerview.datasource = self; pickerview.delegate = self; [actionsheet addsubview:pickerview]; [pickerview release]; uisegmentedcontrol *closebutton = [[uisegmentedcontrol alloc] initwithitems:[nsarray arraywithobject:nslocalizedstring(@"done", @"")]]; closebutton.momentary = yes; closebutton.frame = cgrectmake(260, 7.0f, 50.0f, 30.0f); closebutton.segmentedcontrolstyle = uisegmentedcontrolstylebar; closebutton.tintcolor = [uicolor blackcolor]; [closebutton addtarget:self action:@selector(dismissactionsheet:) forcontrolevents:uicontroleventvaluechanged]; [actionsheet addsubview:closebutton]; [closebutton release]; [actionsheet showinview:self.view]; [actionsheet setbounds:cgrectmake(0, 0, 320, 485)];
and how value when "done" clicked.
you've set delegate of alert, , picker already. have implement them. don't fill in data picker, picker asks delegate data.
you need mandatory functions defined in these 3 protocols.
uipickerviewdelegate
uipickerviewdatasource
uiactionsheetdelegate
you have implement -(ibaction)dismissactionsheet:(uibutton *)sender
too.
and how value when "done" clicked.
i store value instance variable every time picker changes, , once done button clicked assign data model.
edit: if want learn rid of copy&paste solution , try implement on own. ymmv.
Comments
Post a Comment