标签: react-native-ios

文本省略号溢出

我在获取我认为是在 react-native 中实现的简单布局时遇到了一些麻烦。

基本上我需要连续两个视图,他们的父母有justifyContent: 'space-between'.

在第一个视图上有两个文本组件,其中一个在增长时必须有一个省略号。

我所期望的:

在此处输入图片说明

相反,我得到的是该文本组件溢出:

在此处输入图片说明

    <View style={{ flexDirection: 'row', justifyContent: 'space-between', flex: 1 }}>

      <View style={{ flex: 1, flexDirection: 'row' }}>
        <Text>AVATAR</Text>
        <View style={{ marginHorizontal: 15 }}>
          <Text numberOfLines={1}>THIS IS A LONG LONG LONG DESCRIPTION</Text>
        </View>
      </View>

      <View>
        <Text>9,999,999,999.99</Text>
      </View>

    </View>
Run Code Online (Sandbox Code Playgroud)

一个可以玩的沙盒示例:https : //snack.expo.io/HkeFQbyvf

css flexbox reactjs react-native react-native-ios

2
推荐指数
1
解决办法
1436
查看次数

检测何时在 React Native 应用程序中启动其他应用程序

我希望我的本机应用程序能够检测 Google 地图应用程序何时打开以显示一些旅行提示。是否可以?

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

2
推荐指数
1
解决办法
753
查看次数

在 React Native 中使用 AsyncStorage 的异步辅助函数

我想要做的是提醒company_id本地存储中的那个。

import React, { Component } from 'react';
import { ActivityIndicator, AsyncStorage, Button, StatusBar, Text, StyleSheet, View, } from 'react-native';
import * as pouchDB_helper from '../utils/pouchdb';

type Props = {};
export default class HomeScreen extends Component<Props> {

  render() {

    AsyncStorage.getItem('company_id', (err, result) => {
      alert(result);
    });

    return (
      <View style={styles.container}>
        <Button title="Hi" onPress={this.doSomething} />
      </View>
    );
  }

}
Run Code Online (Sandbox Code Playgroud)

以下代码有效,但我希望能够从辅助函数内部执行此操作。如果你在顶部看到,我有import * as pouchDB_helper from '../utils/pouchdb';

在那里我有以下内容:

import React from 'react';
import { AsyncStorage } from 'react-native';
import PouchDB …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-native-ios

2
推荐指数
1
解决办法
2167
查看次数

强制焦点 ReactNative TextInput

我在强制聚焦本机 TextInput 字段时遇到了麻烦。当页面加载autofocus={true}.

但是在模糊之后,我需要按下文本输入字段,但由于设计原因,这是隐藏的。有没有办法document.getElementById("myText").focus();反应原生,我可以在之后调用onBlur()

干杯。

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

2
推荐指数
1
解决办法
1万
查看次数

react-native-maps fitToSuppliedMarker/fitToCorodinates 不显示所有标记

我正在尝试使用简单的 MapView 并显示 2 个标记。

它们都在地图视图上正确显示,但在屏幕上不可见(默认渲染 Image1)

在屏幕上可以看到两个标记之前,我必须执行手动拖动操作。(我手动拖动地图后的图像2,以便它们可以在屏幕上看到)

我尝试使用 fitToSuppliedMarkers/fitToCocordinates 但似乎没有任何效果。

export default class FavItemMapView extends Component{

constructor(props){
    super(props)
    this.state={
        position:{
            latitude:1.286353,
            longitude:103.853067,
            latitudeDelta: 0,
            longitudeDelta: 0,
        },
        error:null
    }
    this.mapRef = null;
}

componentWillMount(){

    const favPlaceLatitude = parseFloat(this.props.navigation.state.params.latitude)
    const favPlaceLongitude = parseFloat(this.props.navigation.state.params.longitude)
    markers.push({latitude:favPlaceLatitude,longitude:favPlaceLongitude});
    navigator.geolocation.getCurrentPosition(
        (position) => {
          console.log("wokeeey" + width + height);
          console.log(position);
          var lat = parseFloat(position.coords.latitude)
          var long = parseFloat(position.coords.longitude)

          var initialRegion = {
            latitude: lat,
            longitude: long,
            latitudeDelta: LATITUDE_DELTA,
            longitudeDelta: LONGITUDE_DELTA,
          }

          this.onRegionChange(initialRegion)
        },
        (error) => this.setState({ …
Run Code Online (Sandbox Code Playgroud)

ios react-native react-native-ios react-native-maps

2
推荐指数
1
解决办法
7197
查看次数

在抽屉/模式打开时更改本机应用程序中的可访问性焦点

我正在尝试提高 React Native 应用程序的可访问性,但面临以下问题:当用户打开菜单抽屉时,焦点不会更改为模态抽屉内容。相反,向左和向右滑动会聚焦在背景中的内容。

我尝试为抽屉和主要内容区域设置动态无障碍道具:

<NavigationMenu
    importantForAccessibility={isNavigationVisible ? 'yes' : 'no-hide-descendants'}
/>
<DashboardContent
    importantForAccessibility={isNavigationVisible ? 'no-hide-descendants' : 'yes'}
/>
Run Code Online (Sandbox Code Playgroud)

isNavigationVisible抽屉打开时更新的道具在哪里,但这没有效果。

有没有办法在抽屉打开时强制将焦点更改到抽屉?

accessibility reactjs react-native react-native-android react-native-ios

2
推荐指数
1
解决办法
2956
查看次数

React Native 如何在启动画面上设置 Gif 图像?

我创建了新的 React Native 移动应用程序,我需要将 gif 图像设置为初始屏幕。任何示例或源代码都可以帮助我做到这一点。

render() {
    return (
      <View style={styles.container}>
        {/*<BackgroundImage source={Images.splashScreen}*/}
        {/*       style = {{width: 315, height: 383}} />*/}

        <Image
            style={{width: 300, height: 200}}
            source={{uri: 'http://gifsstore.com/public/upload/gifs/15609427721560942769.gif'}} />
      </View>
    );
  }
Run Code Online (Sandbox Code Playgroud)

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

2
推荐指数
1
解决办法
6108
查看次数

FlatList onEndReached 调用 On Load (React Native)

当我在 中使用onEndReached函数时FlatList,它会被自动调用。

下面是这个问题的链接。

关联

是否有可用的解决方案或 iOS 中的任何替代方案?

编辑:

下面是我试过的代码,但这似乎不起作用。

constructor(props){
        super(props);
        this.state = {
            flatListReady:false
        }
    }

    loadMore(){
        if(!this.state.flatListReady){
            return null;
        }
        else{
            alert("End Reached")
        }
    }

    _scrolled(){
        this.setState({flatListReady:true});
    }

    render() {
        return (
            <Layout style={{ flex: 1 }}>

                <FlatList
                    data={listData}
                    renderItem={({item}) => this._renderItem(item)}
                    keyExtractor={(item, index) => item.key}
                    onEndReached={() => this.loadMore()}
                    onEndReachedThreshold={0.5}
                    onScroll={() => this._scrolled()}
                />

            </Layout>
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios react-native-flatlist

2
推荐指数
2
解决办法
3680
查看次数

在 React Native 前台设置 PushNotificationIOS 时发出警告

在 IOS 上设置前台推送通知时,我在 Xcode 上收到以下警告:

Assigning to 'id<UNUserNotificationCenterDelegate> _Nullable' 
from incompatible type 'AppDelegate *const __strong'
Run Code Online (Sandbox Code Playgroud)

此警告出现在此代码段的最后一行:

// Define UNUserNotificationCenter
  UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
  center.delegate = self;
Run Code Online (Sandbox Code Playgroud)

我的应用程序编译并按预期运行。我没有使用objective-c的经验,所以我不知道这是关于什么的。我该如何解决?

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

2
推荐指数
1
解决办法
939
查看次数

react-native-webview 为什么 goBack() 方法不起作用?

我在 Expo 中有一个简单的 React Native 项目,它使用react-native-webview启动一个网站。

这是源代码:

import React from "react";
import { StyleSheet, View, SafeAreaView } from "react-native";
import { AntDesign } from "@expo/vector-icons";

import { WebView } from "react-native-webview";


export default function App() {
  const goback = () => {
    WebView.goBack();
  };

  return (
    <SafeAreaView>
      <WebView source={{ uri: "https://google.co.uk" }} />
      <View style={styles.navbar}>
        <View style={styles.forward}>
          <AntDesign name="right" size={25} color="grey" />
        </View>
        <View style={styles.back}>
          <AntDesign name="left" size={25} color="grey" onPress={goback} />
        </View>
      </View>
    </SafeAreaView>
  );
}

const styles …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-android react-native-ios expo react-native-webview

2
推荐指数
1
解决办法
4267
查看次数