简体   繁体   English

如何在 ObjectC 中为 React Native 桥接 Swift 视图

[英]How to bridge Swift View in ObjectC for React Native

I'am new in this Objc and Swift.我是这个 Objc 和 Swift 的新手。 I need some small example.我需要一些小例子。 I dont know what search.我不知道什么搜索。

Objective C very complicated for me.目标 C 对我来说非常复杂。

Can anyone give any simple example, how in Objective C import Swift View as react-native module?谁能举个简单的例子,如何在Objective C import Swift View as react-native模块中查看?

//this is swift file
import SwiftUI

struct SwiftUIView: View {
    var body: some View {
        Text("Hello, World!")
    }
}
//i need use RCTView and RCTViewManager somehow in ObjectiveC files

Please give some example how import SwiftUIView or any other View from Swift to ObjectC and add export as RCTView请举例说明如何将 SwiftUIView 或任何其他视图从 Swift 导入到 ObjectC 并将导出添加为 RCTView

here's a tutorial how to bridge a native iOS component to react-native https://youtu.be/q5M07Q1JFZw but it's for Alert, if you need to create like a completely custom UI element you will probably need to actually learn swift. here's a tutorial how to bridge a native iOS component to react-native https://youtu.be/q5M07Q1JFZw but it's for Alert, if you need to create like a completely custom UI element you will probably need to actually learn swift. It would be easier to help you, if you would describe what are you actually trying to accomplish.如果你能描述你真正想要完成的事情,那么帮助你会更容易。 Because there are rare scenarios when you actually need to program native UI in a native code.因为在极少数情况下,您实际上需要在本机代码中编写本机 UI。

There's also documentation on importing native modules to react-native https://reactnative.dev/docs/native-modules-intro maybe that can help you.还有关于将本机模块导入 react-native https://reactnative.dev/docs/native-modules-intro的文档可能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从反应原生桥将参数传递给 swift class - How to pass parameter to swift class from react native bridge 如何在反应原生中桥接SceneKit? - How to bridge SceneKit in react native? React-Native iOS - 如何在启动屏幕之后,在初始化 React Native Bridge (iOS) 之前显示视图控制器 - React-Native iOS - How to show a view controller after Launch screen, before initialising react native bridge (iOS) 在 iOS 应用程序中使用 rct 桥来表示 React Native 中的表格视图 - Using an rct bridge in iOS app to represent table view in react native React Native IOS Bridge Native View - 从 JS 端调用 Native Method 的正确方法 - React Native IOS Bridge Native View - proper way to call Native Method from JS side 如何快速获取mp3文件的图片(重要,因为objectc方法不起作用) - how to get mp3 file's artwork in swift(important because the objectc method doesn't work) React Native 桥 IOS 原生模块 undefined - React Native bridge IOS native module undefined 在React Native桥上调用方法时,Bridge是nil,使用单例? - Bridge is nil when calling methods on React Native bridge, use a singleton? 如何使用ObjectC向下拖动以消除模态 - How to drag down to dismiss a modal with ObjectC 在带有 Swift 视图控制器的 React Native 应用程序中使用 Realm 时出错 - Error when using Realm in React Native app with Swift view controller
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM