ios6 - How can I add a row in UIPickerview -
i have uipickerview, green button add new record in uipickerview. can add new record, not appear cause can not change number of rows in component.
how can add record , row in uipickerview?
thanks!
my uipickerview:
https://docs.google.com/file/d/0b26la9znn3custdvx21kuf92mza/edit?usp=sharing
edited: when click on green button, displays uialertview textinput add new value in nsmutablearray, number of records changes. when reloadallcomponents not adds row in uipickerview because set amount in numberofrowsincomponent method.
assume manage nsmutablearray pickerview records. in case have manage 3 methods achive this:
1. green button handling method
-(ibaction) greenbuttonpressed:(id)sender{ // add new record nsmutablearray (mypickerviewrowsarray) [self.mypickerview reloadallcomponents]; }
2. pickeview's datasource method, numberofrowsincomponent
- (nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { return [self.mypickerviewrowsarray count]; }
3. pickerview's delegate method, titleforrow
- (nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { return [self.mypickerviewrowsarray objectatindex:row]; }
to right, make sure set pickerview's delegate, set viewcontroller implement uipickerviewdelegate , uipickerviewdatasource.
hope can use this!
Comments
Post a Comment