标签: react-native-ios

ScrollView弹跳的2种不同背景颜色

我有一个ScrollView顶部有一种背景颜色,底部有另一种不同的颜色.

当用户滚动浏览内容并且视图反弹(弹性过度延伸)时,我怎样才能使背景与顶部或底部一致,具体取决于滚动方向?

javascript react-native react-native-ios

6
推荐指数
4
解决办法
4867
查看次数

由于Abort陷阱而退出服务:反应原生IOS中的6

我有反应原生0.40.0.react-native run-ios命令构建项目成功,但然后应用程序崩溃通知:服务退出由于中止陷阱:6!

我尝试通过点击它手动启动已安装的应用程序,但它在控制台中始终崩溃并出现相同的错误:

2月5日23:25:23 Tony com.apple.CoreSimulator.SimDevice.5050AC21-0E8E-4E59-9561-65AFF770E25A.launchd_sim [42289](UIKitApplication:org.reactjs.native.example.yawaloo [0x973d] [53112]):由于中止陷阱而退出服务:6

这就是全部,我甚至不知道在哪里看.也许是因为更新反应原生0.40?

有任何想法吗?

PS Android运行完美.

ios react-native react-native-ios

6
推荐指数
1
解决办法
2576
查看次数

反应原生 - 屏幕在底部切断

我正在使用带有XCode的iOS模拟器首次构建React Native应用程序,似乎屏幕底部的元素被截断,就好像屏幕只能滚动到目前为止.我已经尝试改变整个容器View的高度,但它并没有改变我可以滚动的距离.我也尝试删除样式,以及更改ViewScrollView,但没有帮助.另一个奇怪的是我需要添加paddingTop,否则,第一个Text是在模拟器中显示的时间

这是代码:

import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Fields from './components/Fields.js'

export default class App extends React.Component {
  render() {
    return (
      <View style={styles.container}>
        <Text>Calculator</Text>
        <Text>1099 Calculator</Text>
        <Fields />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    paddingTop: 50
  },
});
Run Code Online (Sandbox Code Playgroud)

这是没有填充的屏幕顶部 在此输入图像描述

这就是它看起来如何切断 在此输入图像描述

react-native react-native-ios

6
推荐指数
1
解决办法
9341
查看次数

在iOS中,React Native ScrollView从底部被切断

我刚刚开始使用React Native,我遇到了一个我不知道为什么会发生的问题.出于某种原因,我无法滚动到我的底部<ScrollView>.

这是我的代码:https://repl.it/Iqcx/0

谢谢!

javascript react-native react-native-ios

6
推荐指数
4
解决办法
4476
查看次数

如何通知React Native自定义视图的大小已更改?

我正在为React Native iOS编写自定义视图.

基本上我必须使文本尽可能大(基于当前视图的视图).我已经通过覆盖reactSetFrame和更改框架来完成它.唯一的问题是视图的位置是错误的,这是一个截图:

重叠的观点

似乎本地反应的"布局管理器"认为视图的高度为0.

这里的代码:

- (void)reactSetFrame:(CGRect)frame {
  [super reactSetFrame:frame];

  NSLog(@"react set frame %@", NSStringFromCGRect(frame));

  [self fitText:self.text];
}

- (void)fitText:(NSString *)text {
    // ... get the correct font size and expected size    
    [self setFont:font];

    CGRect newFrame = self.frame;

    newFrame.size.height = expectedLabelSize.height;

    NSLog(@"new frame is %@", NSStringFromCGRect(newFrame));

    self.frame = newFrame;
}
Run Code Online (Sandbox Code Playgroud)

基本上当帧发生变化时,我会根据传递的文本使用正确的维度更新帧.

日志输出如下:

2017-06-25 16:43:16.434 ABC[44836:6551225] react set frame {{0, 0}, {375, 0}}
2017-06-25 16:43:16.435 ABC[44836:6551225] new frame is {{0, 0}, {375, 69.197000000000017}}
2017-06-25 16:43:16.435 ABC[44836:6551225] react set …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-ios

6
推荐指数
1
解决办法
519
查看次数

如何在React Native中更改文本输入的文本颜色?

输入的占位符是绿色,但我也想输入绿色的文本(当我键入文本时,文本颜色显示为黑色,这在我的UI中不够明显)。我如何也可以使其绿色?

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

6
推荐指数
3
解决办法
3万
查看次数

如何在react-native IOS中隐藏或删除shadow或bottomBorder

我正在使用react-native-router-flux v4.0库来显示react-native中的导航栏.

我在这里创建了一个自定义导航栏.

这是我的代码:

 _renderLeft() {
    return (
        <TouchableOpacity
            style={{justifyContent: 'flex-start', alignItems: 'flex-start', alignSelf: 'flex-start'}}
        onPress={Actions.pop}>
            <Image
                style={{width: 24, height: 24}}
                resizeMode="contain"
                source={require('../../assets/images/ico_swipe.png')}></Image>
        </TouchableOpacity>
    )
}

_renderMiddle() {
    return (
        <View style={[styles.navBarTitleView]}>
            <Text style={[styles.navBarTitle]}>{this.props.title}</Text>
        </View>
    )
}

_renderRight() {
    return (
        <TouchableOpacity
            style={{justifyContent: 'flex-start', alignItems: 'flex-start', alignSelf: 'flex-start'}}
            onPress={Actions.pop}>
            <Image
                style={{width: 24, height: 24}}
                resizeMode="contain"
                source={require('../../assets/images/ico_home.png')}></Image>
        </TouchableOpacity>
    )
}

render() {
    StatusBar.setBarStyle('light-content', true);
    return (
        <Header style={[styles.container]}>
            <Left style={{flex: 1}}>
                {this._renderLeft()}
            </Left>
            <Body style={{flex: 3}}>
            <Title style={styles.navBarTitle}>{this.props.title}</Title>
            </Body>
            <Right style={{flex: …
Run Code Online (Sandbox Code Playgroud)

react-native react-native-router-flux react-native-ios

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

React-Native调试工具/开发人员菜单在iOS设备上不起作用

我们有一个本机反应项目,可以在模拟器和设备上正常运行。但是,我们无法使用iOS设备上的摇动手势打开开发人员菜单。

我看到了其他问题,但无法解决:https : //github.com/facebook/react-native/issues/5122

我们在Xcode中具有标准配置设置,因此可以使用调试方案进行构建。 调试配置方案

DEBUG = 1设置也被添加到预处理器宏中: 在此处输入图片说明

但是,当摇晃设备时,我只是看起来很愚蠢,菜单没有显示。任何有关如何解决此问题的想法将不胜感激。

ios react-native react-native-ios react-native-debugger

6
推荐指数
1
解决办法
2115
查看次数

在响应本机中处理网络请求失败

使用React Native Fetch API时遇到问题。很多次请求失败。我有高速连接。但是很多次失败了。该问题正在android和ios中同时发生。

const shoppingApi  = 'myserverlink';

async function Sendshoppinapi(data) {
    try {
        let response = await fetch(shoppingApi, {
            method: 'POST',
            headers: {
                'Accept': 'application/json',
                'content-type':'multipart/form-data'
            },
            body: data
        });
        let responseJson = await response.json();
        return responseJson;
    }
    catch (error) {
          Alert.alert(error.toString())
    }
}

export {Sendshoppinapi};
Run Code Online (Sandbox Code Playgroud)

我发送服务器作为后期请求的数据

  add_to_wishlist = (item,index) => {
        {
          let data = new FormData();
        data.append('methodName',       'add_to_wishlist');
        data.append('user_id',        global.userid)
        data.append('item_id',        this.props.navigation.state.params.itemid.toString())


        Sendshoppinapi(data).then((responseJson)=>{

          console.warn(responseJson);
          if(responseJson.responseCode == '200'){
            this.setState({fav:false})
            Alert.alert('SHOPPING','Item added to wishlist successfully.',[{text: 'OK',},],{ cancelable: false }) …
Run Code Online (Sandbox Code Playgroud)

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

6
推荐指数
1
解决办法
8125
查看次数

输入失去对开始输入主题的关注

我正在尝试开发一个react-native应用程序,以设计一个自定义主题组件,并使用将该屏幕包含在主题中this.props.child。问题是屏幕上的输入字段失去焦点,并且在键入每个字符后键盘都被关闭,因为onChange我正在更新状态变量,这可能会重新呈现整个主题。

我已经尝试过在Github上提供许多解决方案,例如将唯一键传递给输入字段,但是它们不起作用。

这是我的主题组件的样子:

import Header from './header'
import footer from './footer'

export default class Theme extends Component {

    render() {
        //------this is my header component----
        <Header/>
        <View>
        //------this is my Body  in which i include my sceen content----
        {this.props.children}
        </View>

         //------this is my footer component----
        <footer/>
    }
}
Run Code Online (Sandbox Code Playgroud)

这是带有输入字段的屏幕:

import Theme from "../../components/Theme";
import { Input, Button } from "react-native-elements";

export default  class ChangePassword extends Component {

    constructor(props) {

    super(props);
    this.state = {

        inputs:{
            old_password : …
Run Code Online (Sandbox Code Playgroud)

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

6
推荐指数
1
解决办法
179
查看次数