无论如何,是否可以使用 React Native 向 TabBarIOS 呈现本机控制器?
Is there anyway to present a native controller to a TabBarIOS with React Native?
我想将 TabBarIOS 集成到本机应用程序中。例如在点击按钮后呈现给 TabBarIOS。
但是当我 运行.
时它被压碎了
在index.ios.js
'use strict';
import React from 'react';
import {
AppRegistry,
} from 'react-native';
import myTabBar from './ios/tab/MyTab.js'
AppRegistry.registerComponent('myTabBar', () => myTabBar);
本机代码:
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "myTabBar",
initialProperties: nil,
launchOptions: nil
)
let vc = UIViewController()
vc.view = rootView
self.presentViewController(vc, animated: true, completion: nil)
错误:
2016-11-16 15:56:51.600 [info][tid:com.facebook.react.JavaScript] Running application "myTabBar" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2016-11-16 15:56:51.611 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTImageView" does not exist
2016-11-16 15:56:51.611 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTVirtualImage" does not exist
2016-11-16 15:56:51.738 swift-2048[5277:144989] -[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00
2016-11-16 15:56:51.739 [error][tid:main][RCTUIManager.m:1100] Exception thrown while executing UI block: -[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00
2016-11-16 15:56:51.758 swift-2048[5277:144989] -[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00
2016-11-16 15:56:51.759 swift-2048[5277:144989] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00'
感谢您的帮助!
看找不到RCTImageView
,我猜你没有包含库。
如果您使用的是 CocoaPods,您会希望它包含 RCTImage
,并且看起来有点像:
platform :ios, '9.0'
target 'YourApp' do
use_frameworks!
# React Native
pod 'React', :path => 'node_modules/react-native', :subspecs => [
'Core',
'RCTImage',
]
end
我想将 TabBarIOS 集成到本机应用程序中。例如在点击按钮后呈现给 TabBarIOS。 但是当我 运行.
时它被压碎了在index.ios.js
'use strict';
import React from 'react';
import {
AppRegistry,
} from 'react-native';
import myTabBar from './ios/tab/MyTab.js'
AppRegistry.registerComponent('myTabBar', () => myTabBar);
本机代码:
let rootView = RCTRootView(
bundleURL: jsCodeLocation,
moduleName: "myTabBar",
initialProperties: nil,
launchOptions: nil
)
let vc = UIViewController()
vc.view = rootView
self.presentViewController(vc, animated: true, completion: nil)
错误:
2016-11-16 15:56:51.600 [info][tid:com.facebook.react.JavaScript] Running application "myTabBar" with appParams: {"rootTag":1,"initialProps":{}}. __DEV__ === true, development-level warning are ON, performance optimizations are OFF
2016-11-16 15:56:51.611 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTImageView" does not exist
2016-11-16 15:56:51.611 [warn][tid:com.facebook.react.JavaScript] Warning: Native component for "RCTVirtualImage" does not exist
2016-11-16 15:56:51.738 swift-2048[5277:144989] -[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00
2016-11-16 15:56:51.739 [error][tid:main][RCTUIManager.m:1100] Exception thrown while executing UI block: -[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00
2016-11-16 15:56:51.758 swift-2048[5277:144989] -[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00
2016-11-16 15:56:51.759 swift-2048[5277:144989] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RCTCustomScrollView refreshControl]: unrecognized selector sent to instance 0x7febe1099c00'
感谢您的帮助!
看找不到RCTImageView
,我猜你没有包含库。
如果您使用的是 CocoaPods,您会希望它包含 RCTImage
,并且看起来有点像:
platform :ios, '9.0'
target 'YourApp' do
use_frameworks!
# React Native
pod 'React', :path => 'node_modules/react-native', :subspecs => [
'Core',
'RCTImage',
]
end