反应原生触摸多选功能

时间:2020-06-17 13:08:37

标签: react-native touch-event

我正在尝试实现下一个功能:当用户用手指触摸屏幕并移动它时-选择了用户浏览过的所有基本按钮(如果可能的话-跟踪所有按钮名称)

这是按钮的示例代码 我试图做的是: 1.跟踪父视图的onTouchStart,onTouchMove和onTouchEnd事件; 我可以获取节点目标ID,但是无法将其交换为按钮组件 2.为每个按钮设置onTouchStart和onTouchEnd事件。 如果我从按钮1转到按钮2-我无法触发或传播第二个按钮的触摸事件

任何帮助将不胜感激

import React from 'react';
import {View, Button} from 'react-native';

class SampleTable extends React.Component {

    constructor() {
        super();
    }

    render() {
        return (
            <View>
                <View
                    style={[{ width: "90%", margin: 10, backgroundColor: "gray" }]}>
                    <Button
                        title="Button One"
                        color="gray"
                    />
                </View>
                <View
                    style={[{ width: "90%", margin: 10, backgroundColor: "gray" }]}>
                    <Button
                        title="Button Two"
                        color="gray"
                    />
                </View>
            </View>
        );
    }
}

export default SampleTable

0 个答案:

没有答案