如何在本机中同时启用触摸多个按钮? [英] How do I enable touch on multiple buttons simultaneously in react native?
问题描述
我需要当我触摸并按住一个按钮时,我也应该能够触摸按钮1.
I need that when I am touching and holding one button then I should also be able to touch on the button 1.
<View>
<View
onStartShouldSetResponder={()=>this.console("Button 2 Clicked")}>
<Text>BUTTON 2</Text>
</View>
<TouchableOpacity
onPressIn={()=>this.console('Button 1 pressed')}
onPressOut={()=>this.console('Button 1 released')}>
<View>
<Text>BUTTON 1</Text>
</View>
</TouchableOpacity>
</View>
基本上,我有一个屏幕,我可以通过点击并按住录制按钮(按钮1)来录制视频。在同一个屏幕上,我有一个翻盖相机按钮(按钮2)。我希望我能够在录制视频时点击翻盖相机按钮。
Basically, I have a screen where I can record a video by tapping and holding the record button(Button 1). On the same screen, I have a flip camera button (Button 2). I want that I should be able to click on the flip camera button while I am recording the video.
推荐答案
这个问题很容易使用onTouchStart,onTouchEnd道具的View组件解决,而不使用手势响应方法。
This problem can easily be resolved using onTouchStart, onTouchEnd props of View component without using gesture responder methods.
所以修改后的代码看起来像
So the modified code will look like
<View>
<View onTouchStart={()=>this.console("Button 2 Clicked")}>
<Text>BUTTON 2</Text>
</View>
<View
onTouchStart={()=>this.console('Button 1 pressed')}
onTouchEnd={()=>this.console('Button 1 released')}>
<Text>BUTTON 1</Text>
</View>
</View>
这篇关于如何在本机中同时启用触摸多个按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!