小编sam*_*b90的帖子

React Native - 获取POST请求作为GET请求发送

我在使用FETCH时遇到问题.

我试图在react-native中使用FETCH发出POST请求.

    fetch("http://www.example.co.uk/login", {
        method: 'POST',
        headers: {
            'Accept': 'application/json',
            'Content-Type': 'application/json'
        },
        body: JSON.stringify({
            username: 'test',
            password: 'test123',
        })
    })

        .then((response) => response.json())
        .then((responseData) => {
            console.log(
                "POST Response",
                "Response Body -> " + JSON.stringify(responseData)
            )
        })
        .done();
}
Run Code Online (Sandbox Code Playgroud)

当我使用Charles检查此调用时,它被记录为GET请求,并且不存在应该在正文中的用户名和密码.

在此输入图像描述

有人可以帮忙解决这个问题吗?

react-native

11
推荐指数
4
解决办法
4万
查看次数

React Native - 按下按钮动态添加元素到DOM

在本机中,我试图在按钮点击时动态地向DOM添加元素.

这是我到目前为止在Render()方法中所拥有的:

<TouchableHighlight  
    style={styles.button} 
    onPress={this.addAnotherRow}>

        <Text>Add new row</Text>

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

我不知道从onpress函数返回什么来添加另一个DOM元素:

addAnotherRow() {
    return <Text>New Row</Text>
}
Run Code Online (Sandbox Code Playgroud)

有什么帮助吗?

react-native

11
推荐指数
1
解决办法
8223
查看次数

React Native从内部函数访问this.prop

我有以下代码:

module.exports = class Menu extends Component {

    about() {
        this.props.nav.push({
            component: TestView,
            title: 'Test View',
        });
    }

    render() {
        return (
            <ScrollView
                scrollsToTop={false}
                style={styles.menu}
                navigator={this.props.nav}>
                <View style={styles.logoContainer}>
                    <Image
                        style={styles.logo}
                        source={{ uri, }}/>
                </View>

                <Text onPress={this.about} style={styles.item}>About</Text>
                <Text style={styles.item}>Account</Text>
            </ScrollView>
        );
    }
};
Run Code Online (Sandbox Code Playgroud)

我一直收到错误消息:

"undefined is not an object ("evaluating this.props.nav") 
Run Code Online (Sandbox Code Playgroud)

当"onPress"调用"this.about"时.我在render函数中放置了一个console.log,我可以看到this.props.nav包含一个值.问题出现在about()函数中,我不知道为什么.

任何建议都会很棒吗?

谢谢

react-native

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

在NSDictionary中存储C float数组

我想存储c-float arrayNSDictionary以后使用.
我最初使用的NSArray是存储C数据但是NSArray为了减慢我的意图.

我使用以下代码将数组包装在NSDictionary中:

[self.m_morphPositions setObject:[NSValue valueWithBytes:&positionBuff objCType:@encode(float[(self.m_countVertices * 3)])] forKey:fourCC];
Run Code Online (Sandbox Code Playgroud)

并使用以下方法检索C-Float数组:

float posMorphs[(self.m_countVertices*3)];

NSValue *posValues = [self.m_morphPositions objectForKey:name];

[posValues getValue:&posMorphs];
Run Code Online (Sandbox Code Playgroud)

当我退出数组时,对于每个错误的索引,值都设置为0.0.

我怎样才能解决这个问题?

xcode opengl-es objective-c ios

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

pixelStorei(gl.UNPACK_FLIP_Y_WEBGL,true);

如果使用OpenGL ES,我一直试图找出相应的行,UNPACK_FLIP_Y_WEBGL.我一直无法找到解决方案.

有人可以帮我找一个等价的吗?

问候

javascript xcode objective-c webgl ios

3
推荐指数
1
解决办法
2946
查看次数

自定义委派方法不适用于iOS

我创建了一个自定义委托方法来更新ViewController的背景颜色.我无法得到委托方法来回应.这是我的代码:

VASettingsView.h

#import <UIKit/UIKit.h>
#import <GLKit/GLKit.h>

@class VASettingsView;

@protocol VASettingsViewDelegate <NSObject>
- (void)setNewBackgroundColour:(GLKVector4)newColour;
@end

@interface VASettingsView : UIView {
    id <VASettingsViewDelegate> delegate;
}

@property (strong, nonatomic) IBOutlet UIButton *blackBackgroundButton;
@property (strong, nonatomic) IBOutlet UIButton *saveButton;

@property GLKVector4 backgroundColourSetting;

// Set delegate method
@property (nonatomic,weak)id delegate;

- (IBAction)blackButtonPressed:(id)sender;
- (IBAction)saveButtonPressed:(id)sender;

@end
Run Code Online (Sandbox Code Playgroud)

VASettingsView.m

#import "VASettingsView.h"

@implementation VASettingsView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {

    }
    return self;
}

- (IBAction)blackButtonPressed:(id)sender {
    self.backgroundColourSetting = GLKVector4Make(0.0, 0.0, 0.0, 0.0);
}
- …
Run Code Online (Sandbox Code Playgroud)

xcode objective-c ios

3
推荐指数
1
解决办法
4393
查看次数

标签 统计

ios ×3

objective-c ×3

react-native ×3

xcode ×3

javascript ×1

opengl-es ×1

webgl ×1