You can try linking the project automatically:
$ react-native link
or do it manually as described below:
- Run
npm install react-native-horizontal-picker --save
or:
- Open your project in XCode, right click on
Libraries
and clickAdd Files to "Your Project Name"
Look undernode_modules/react-native-horizontal-picker
and addRNTHorizontalPicker.xcodeproj
. - Add
libRNTHorizontalPicker.a
toBuild Phases -> Link Binary With Libraries
- Click on
libRNTHorizontalPicker.xcodeproj
inLibraries
and go theBuild Settings
tab.
Then:
- Whenever you want to use it within React code now you can:
import HorizontalPicker from 'react-native-horizontal-picker';
<HorizontalPicker
selectedIndex={0} //initial index can be set using this
style={{ width: 150, height: 100, marginBottom: 4 }} //styles usually given to View component
titles={[1, 2, 3, 4]} //can be an array of numbers or strings
onChange={(event: Event) => { console.log('index of selected value', event.nativeEvent.newIndex); }}
/>
- Add test cases
- More UI customization support
- Android support
- Support for images
This component is based on akkyie's component AKPickerView. License: https://github.com/Akkyie/AKPickerView/blob/master/LICENSE
MIT.