ios - UIPickerView content flowing unexpectedly -
i using uidatepicker
, uipickerview
in app. both controls showing weird behaviour. when scroll content in picker, flows outside picker , not scroll supposed to. implementation below.
sexarray = @[@"male", @"female"]; uipickerview *picker = [[uipickerview alloc] initwithframe:cgrectmake(0, 50, 100, 150)]; [picker setdatasource: self]; [picker setdelegate: self]; picker.showsselectionindicator = yes; gendertf.inputview = picker; #pragma mark -- uipickerview methods -(nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component{ return sexarray.count; } -(nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview{ return 1; } - (uiview *)pickerview:(uipickerview *)pickerview viewforrow:(nsinteger)row forcomponent:(nsinteger)component reusingview:(uiview *)view { uilabel *retval = (uilabel*)view; if (!retval) { retval = [[uilabel alloc] initwithframe:cgrectmake(0.0f, 0.0f, 100, [pickerview rowsizeforcomponent:component].height)]; } retval.font = [uifont fontwithname:@"sourcesanspro-regular" size:15.0f]; retval.minimumscalefactor = 0.6; [retval settextalignment:nstextalignmentcenter]; retval.text = [sexarray objectatindex:row]; return retval; } -(void)pickerview:(uipickerview *)pickerview didselectrow:(nsinteger)row incomponent:(nsinteger)component{ [gendertf settext:sexarray[component]]; }
when same code used in app (for testing), works expected.
turns out implementation correct on part. problem because of third party library.
i using pod slpagingview
in project made `uipickerview' act weird. couldn't find solution , ended in replacing pod similar pod.
details link
Comments
Post a Comment