ios - Add User data to UIPickerView -
ios - Add User data to UIPickerView -
i have app user scans qr code nsstring, need set uipickerview.
what utilize set text of uipickerview row nsstring qr code?
firstly, need have array of strings , implement uipickerviewdatasource , uipickerviewdelegate in .h file. after this, have create utilize of delegate methods of uipickerview shown :
-(nsinteger)numberofcomponentsinpickerview:(uipickerview *)pickerview { //return number. }
this homecoming number of sections want in pickerview.
(nsinteger)pickerview:(uipickerview *)pickerview numberofrowsincomponent:(nsinteger)component { homecoming array.count; }
the above method homecoming number of rows in particular component. if have array, equal number of elements in array. , lastly one.
-(nsstring *)pickerview:(uipickerview *)pickerview titleforrow:(nsinteger)row forcomponent:(nsinteger)component { nsstring *str; if(pickerview == yourpickername) { str = [array objectatindex:row]; } homecoming str; }
this method homecoming text value each row in picker. , don't forget connect pickerview's datasource , delegate in storyboard.
hope helps.
ios uipickerview
Comments
Post a Comment