解决 ReactNative 使用 CameraRoll 时 undefined 错误

1,403 阅读1分钟

最近在学习 ReactNative ,写到 CameraRoll 相关的 CameraRoll Demo 时候,一直出现 Cannot read property 'getPhotos' of undefined 错误。

这里 return 的 RCTCameraRollManager.getPhotos(params); 是一个原生的模块 :

var RCTCameraRollManager = require('NativeModules').CameraRollManager;

研究了一下工程,发现根本没有相关的项目,只好手动添加,步骤如下:

RCTCameraRoll.xcodeproj 工程添加到现有工程中:

路径位于 node_modules/react-native/Libraries/CameraRoll

添加静态库依赖:

大功告成:

原文链接:blog.yourtion.com/fix-reactna…