React-native:tvOS 如何强制按钮聚焦? [英] React-native: tvOS How to force a Button to be focused?
本文介绍了React-native:tvOS 如何强制按钮聚焦?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可以强制按钮聚焦吗?我知道用户可以聚焦一个元素,但我想以编程方式进行
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
推荐答案
是的,如果你想强制一个可聚焦的组件成为焦点,你只需要将 hasTVPreferredFocus 设置为 true
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
例如:
<TouchableHighlight
hasTVPreferredFocus={true}
onPress={() => {}}
>
<Text>Hello</Text>
</TouchableHighlight>
这篇关于React-native:tvOS 如何强制按钮聚焦?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文