ios - 无论如何,是否可以使用 React Native 向 TabBarIOS 呈现 native Controller ?

标签 ios swift react-native react-native-ios

我想将 TabBarIOS 集成到 native 应用程序中。例如点击按钮后呈现给 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);

native 代码:

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

关于ios - 无论如何,是否可以使用 React Native 向 TabBarIOS 呈现 native Controller ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40627144/

相关文章:

ios - Swift-在UITableView中显示按日期排序的自定义对象数组

ios - 存储用户信用信息

iOS 9 [locationManager.requestWhenInUseAuthorization()] 警报 View 出现后很快消失

react-native - 更新由 : AIRMapMarker (React native) 管理的 View 的属性 'coordinate' 时出错

javascript - 如何使数组处于状态并处理handleFormChange

ios - 在swift中点击一个颜色 Sprite 后如何返回到之前的场景?

ios - 如何动画 CAShapeLayer 路径变化?

swift - 点击远程通知后导航栏丢失

swift - 如何在 Swift 中检索网页的 HTML 代码

javascript - 针对不同架构的 React Native 发布版本创建了 4 个 apk