React Native Image Picker:“undefined不是对象(评估'ImagePickerManager.showImagePicker')”

时间:2017-05-15 15:36:41

标签: javascript react-native react-native-android react-native-ios react-native-image

我跟随react-native-image-picker的自述文件进行了手动和自动链接(单独尝试)。

当我使用react-native run-ios从终端启动模拟器时,我收到错误消息。从Xcode启动它工作正常,我可以访问CameraRoll选择器没问题。

以下是我正在使用的版本:

"react-native": "0.43.3", "react-native-image-picker": "^0.26.3",

我在这里看到了一个类似的帖子stackoverflow,似乎我不是唯一有这个问题的人。

感谢您的帮助。

完整错误:

undefined is not an object (evaluating 'ImagePickerManager.showImagePicker')

showImagePicker
    index.js:28:30
selectPhotoTapped
    CamPick.js:31:32
touchableHandlePress
    TouchableOpacity.js:126:45
_performSideEffectsForTransition
    Touchable.js:746:34
_receiveSignal
    Touchable.js:664:44
touchableHandleResponderRelease
    Touchable.js:433:24
invokeGuardedCallback
    ReactErrorUtils.js:30:9
executeDispatch
    EventPluginUtils.js:99:42
executeDispatchesInOrder
    EventPluginUtils.js:127:20
executeDispatchesAndRelease
    EventPluginHub.js:37:46
forEachAccumulated
    forEachAccumulated.js:30:16
processEventQueue
    EventPluginHub.js:227:8
runEventQueueInBatch
    ReactEventEmitterMixin.js:18:35
handleTopLevel
    ReactEventEmitterMixin.js:38:25
<unknown>
    ReactNativeEventEmitter.js:113:8
perform
    Transaction.js:149:24
batchedUpdatesWithControlledComponents
    ReactGenericBatching.js:51:26
_receiveRootNodeIDEvent
    ReactNativeEventEmitter.js:111:40
receiveTouches
    ReactNativeEventEmitter.js:200:8
__callFunction
    MessageQueue.js:244:47
<unknown>
    MessageQueue.js:108:26
guard
    MessageQueue.js:46:4
callFunctionReturnFlushedQueue
    MessageQueue.js:107:10

1 个答案:

答案 0 :(得分:2)

似乎Xcode没有正确链接文件,为我工作的诀窍是:

  1. 打开Xcode项目&#39; MainProject.xcodeproj&#39;
  2. 在图书馆下的MainProject下,我会找到RNImagePicker.xcodeproj
  3. 在RNImagePicker.xcodeproj下,我会右键单击并删除文件ImagePickerManager.h和ImagePickerManager.m
  4. 右键单击RNImagePicker.xocdeproj以“将文件添加到...&#39;然后从&#39; node_modules / react-native-maps / ios / ImagePickerManager.h和ImagePickerManganer.m&#39;
  5. 中选择两个文件

    希望它可以帮助那些可能遇到同样问题的人;)