React-native: tvOS How to force a Button to be focused?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-05 04:28:06

问题


It is possible to force a button to be focused ? I know the user can focused an element but I want to make it programmatically


回答1:


Yes it is possible, with tvOS and react native if you want to force a focusable component to be focus you just need to set hasTVPreferredFocus to true

For example:

<TouchableHighlight
    hasTVPreferredFocus={true}
    onPress={() => {}}
>
    <Text>Hello</Text>
</TouchableHighlight>


来源:https://stackoverflow.com/questions/43862802/react-native-tvos-how-to-force-a-button-to-be-focused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!