标签: react-native-ios

如何一次全局设置自定义字体系列并在整个本机应用程序中使用而不调用每个“文本”组件?

根据此堆栈溢出解决方案,可以通过在每个Text组件中调用自定义字体来使用它。但是当我们Text的应用程序中有数千个组件时,我们可能会碰巧错过相同的字体系列。然后我们在字体系列的情况下失去一致性。

因此,有没有办法通过不调用每个Text组件来使用自定义字体系列?

react-native react-native-android react-native-ios

5
推荐指数
1
解决办法
7114
查看次数

如何在ios stimulator中查看react-native创建的realm db

我想访问由我使用 react-native 创建的 ios 应用程序创建的领域数据库。它更容易adb pull用于 android 但对于 ios 我不太了解。有一些链接,如 -

  1. ios 应用程序中的领域文件
  2. 为上述链接查找应用程序 uuid

所以任何帮助,如何查看领域数据库以开发和调试 react-native 开发的 ios 应用程序。

感谢您的回答,但额外的(出于好奇)问题 - 但如何找到通过 react native 在 ios 模拟器上安装的应用程序 uid ?

realm react-native react-native-ios realm-mobile-platform

5
推荐指数
1
解决办法
1980
查看次数

如何在 React Native 中备份/恢复 SQLite 数据库

我正在使用andpor/react-native-sqlite-storage在 React Native 中管理 SQLite 数据库。现在我想将我的所有数据库备份到一个加密文件中,然后在以后恢复它。我知道如何在 android 中做到这一点,但不知道如何在 react native 中实现这一点。

如果它在android中,下面的代码可以帮助我在不加密的情况下备份数据库。

 final String inFileName = "/data/data/<your.app.package>/databases/foo.db";
File dbFile = new File(inFileName);
FileInputStream fis = new FileInputStream(dbFile);

String outFileName = Environment.getExternalStorageDirectory()+"/database_copy.db";

// Open the empty db as the output stream
OutputStream output = new FileOutputStream(outFileName);

// Transfer bytes from the inputfile to the outputfile
byte[] buffer = new byte[1024];
int length;
while ((length = fis.read(buffer))>0){
    output.write(buffer, 0, length);
}

// Close the streams
output.flush();
output.close();
fis.close();
Run Code Online (Sandbox Code Playgroud)

所以我的问题是如何在 React …

sqlite react-native react-native-android react-native-ios

5
推荐指数
1
解决办法
1695
查看次数

说请将方法附加到此组件

我是本机反应的新手,我正在尝试向我的 API 发送一些数据,基本上是一个 POST 请求,添加了一个按钮并尝试使用它来调用获取请求,但我不确定我做错了什么这个 ??它在日志中显示“请将方法附加到此组件”,如果我在这方面做错了什么,请告诉我?

这是我的按钮

<Button
        style={{height: 60,width:150}}
        onClick={ () => this.submitNewCustomer()}
        title="SUBMIT"
        backgroundColor='#C0C0C0'
        color="black"
        />
Run Code Online (Sandbox Code Playgroud)

这是我的方法

submitNewCustomer(){
fetch('http://endpoint.net/api/customerdetail', {
  method: 'POST',
  headers: new Headers({
            'Content-Type': 'application/json', // <-- Specifying the Content-Type
    }),
  body: JSON.stringify({
    CustomerId: '1ef87a90-a941-4ebb-b101-66f74ac07778',
    CustomerName: this.state.customername,
    UserId:'user2',
    VehicleCompanyName:this.state.vehiclecompanyname,
    VehicleModelType:this.state.vehiclemodeltype,
    VehicleNumber:this.state.vehiclenumber,
    CustomerImage:'',
    Location:'',
    CustomerImageType:'png'
  }), // <-- Post parameters
})
.then((response) => response.text())
.then((responseText) => {
  alert(responseText);
})
.catch((error) => {
    console.error(error);
});

}
Run Code Online (Sandbox Code Playgroud)

任何输入都会非常有帮助

fetch react-native react-native-android react-native-ios

5
推荐指数
1
解决办法
4333
查看次数

React Native TextInput 不会以正确的内容长度增加高度

我正在尝试使用 react native 元素和 react native 实现多行扩展文本输入,但我似乎无法让它正常运行。该行为显示在以下屏幕截图中:

正如你在这里看到的,文本有明显不止一行,但文本输入并没有展开。

在此处输入图片说明

每当我输入更多字符时,它都会扩展一点,但会向下扩展到键盘中。

在此处输入图片说明

添加另一行不会扩展键盘:

在此处输入图片说明

直到我添加更多字符,直到最新行是文本输入宽度的一半,输入才会展开

在此处输入图片说明

这是我用于文本输入的代码:

<View style={{flexDirection:'row', backgroundColor: 'transparent', height: Math.max(45, this.state.viewHeight)}}>
<Input
          containerStyle={{marginVertical: 0, width:300, marginLeft: 10}}
          inputStyle={[styles.textInput, {height: Math.max(35, this.state.height)}]}
          multiline
          enablesReturnKeyAutomatically={true}
          keyboardAppearance="dark"
          placeholder=""          
          onContentSizeChange={(event) => {
            if (this.state.height <= (35*6)){
            this.setState({
               height: event.nativeEvent.contentSize.height,
              viewHeight: event.nativeEvent.contentSize.height })
            }
          }}
          onChangeText={(message) => { this.setState({message})
        }}
Run Code Online (Sandbox Code Playgroud)

这是我的文本输入样式的代码:

textInput: {
      paddingHorizontal: 12,
      width: 100,
      backgroundColor: '#F0F0F0',
      borderStyle: 'solid',
      marginLeft: -4,
      overflow: 'hidden',
      marginTop: 5,
      borderWidth: 1,
      borderColor: 'lightgrey',
      borderRadius: 25,
    },
Run Code Online (Sandbox Code Playgroud)

似乎内容大小更改事件在错误的时间触发,有什么方法可以将其设置为仅在新行具有特定长度并向上扩展而不是向下扩展到键盘时触发?

javascript textinput react-native react-native-ios

5
推荐指数
1
解决办法
3306
查看次数

在调试模式下运行项目时,Xcode 中未设置 DEBUG 宏

我创建了一个新的 React-Native 项目,其中包含一个 Android 项目和一个 iOS 项目。我使用的是 Swift,因此我将AppDelegate.mAppDelegate.h文件替换为AppDelegate.swift. 我在 swift 文件中使用DEBUG这样的宏,但即使在调试模式下它也始终设置为 false,因此我无法使用它。

    #if DEBUG
      let jsCodeLocation = RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index", fallbackResource:nil)
    #else
      let jsCodeLocation = Bundle.main.url(forResource: "main", withExtension: "jsbundle")
    #endif
Run Code Online (Sandbox Code Playgroud)

debug我在 Xcode上搜索Build Settings,发现下面的内容似乎设置正确。

在此输入图像描述

如何确保DEBUG在运行调试模式时设置宏,而不是在其他情况下设置宏。谢谢。

xcode ios react-native react-native-ios

5
推荐指数
1
解决办法
843
查看次数

如何解决React Native iOS中的“架构armv7的未定义符号”?

我在构建发布 React Native ios 时遇到问题,我尝试寻找许多示例,但全部失败。

这是错误消息:

Undefined symbols for architecture armv7:
  "_RCTDefaultLogFunction", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
  "_RCTSharedApplication", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
  "_RCTSetLogFunction", referenced from:
      -[momsindonesiaTests testRendersWelcomeScreen] in momsindonesiaTests.o
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

我不知道如何再次解决这个错误,请帮我解决这个问题。

谢谢。

xcode ios swift react-native react-native-ios

5
推荐指数
1
解决办法
4775
查看次数

本机 UI 组件抛出不变违规:尝试注册两个同名的视图 FridgeCameraView

尝试学习 React Native 自定义本机 UI 组件。

// FridgeCameraViewManager.swift

import UIKit

@objc(FridgeCameraViewManager)
class FridgeCameraViewManager: RCTViewManager {

  override func view() -> UIView! {
    let label = UILabel()
    label.text = "Swift Component"
    label.textAlignment = .center
    return label
  }

  @objc static override func requiresMainQueueSetup() -> Bool {
    return false
  }
}
Run Code Online (Sandbox Code Playgroud)

// FridgeCameraViewManager.h

#import <Foundation/Foundation.h>
#import "React/RCTViewManager.h"

@interface RCT_EXTERN_MODULE(FridgeCameraViewManager, RCTViewManager)


@end
Run Code Online (Sandbox Code Playgroud)

// FridgeCameraView.js

import {requireNativeComponent} from 'react-native';
const FridgeCameraView = requireNativeComponent('FridgeCameraView', null);
export default FridgeCameraView;
Run Code Online (Sandbox Code Playgroud)

当我尝试在 App.js 中的某处使用 FridgeCameraView 组件时,它仅在我使用 Xcode 构建并运行项目时才有效。否则,在更改某些内容时使用热重载,我会收到“不变违规:尝试注册两个具有相同名称的视图 …

ios react-native react-native-ios react-native-native-ui-component

5
推荐指数
1
解决办法
970
查看次数

iPad OS 是否可以检测键盘是否处于浮动模式?

我们遇到了一个特定的错误iOS/iPadOS,当 iPad 在屏幕上显示浮动(类似 iPhone)键盘(而不是固定键盘)时,该错误似乎会被触发。

我们的问题特定于 React Native 和KeyboardAvoidingView组件。当组件渲染并且键盘浮动时,KeyboardAvoidingView完全错误地计算了键盘所需的高度,并隐藏了大约 95% 的屏幕高度。

本身KeyboardAvoidingView似乎没有办法检测浮动键盘是否打开。

是否有一个特定的 API 可以用来检测此键盘模式,以便我们可以关闭它KeyboardAvoidingView

键盘事件(keyboardWillShowkeyboardDidShow等)似乎没有返回任何具体线索。

objective-c ipad ios react-native react-native-ios

5
推荐指数
1
解决办法
1583
查看次数

如何在react-native-video中隐藏声音和全屏按钮

在视频屏幕中隐藏声音和全屏图标的任何选项。我正在使用react-native-video 包。

在此输入图像描述

react-native react-native-ios react-native-video

5
推荐指数
0
解决办法
461
查看次数