React Native Elements - 在输入周围包裹可触摸的不透明度在 IOS 中不起作用

React Native Elements - Wrapping a touchable opacity around an input does not work in IOS

我在使用 React Native Elements 文本输入以及使用可触摸不透明度时遇到了一个非常特殊的问题。

import React, { useState } from 'react';
import { TouchableOpacity, View, Dimensions } from 'react-native';
import { Input } from 'react-native-elements';

const test = () => (
  <TouchableOpacity onPress={() => console.log('we hit here')}>
    <Input disabled>
      {children}
    </Input>
  </TouchableOpacity>
)

export default test;

所以输入框的外缘是完全可以点击的,但是组件的中心是不能点击的。

然而,这非常适合 android。

任何想法

如果有人遇到这个问题,那么您需要向 'none' 提供一个 pointerEvents 以使整个组件可点击:

<View pointerEvents='none'>
<Input disabled>
      {children}
    </Input>
</View>

Mubeen hussain 的回答是正确的,但更准确地说是这样的

<TouchableOpacity onPress={() => console.log('we hit here')}>
  <View pointerEvents="none">
    <Input disabled>{children}</Input>
  </View>
</TouchableOpacity>