gpt4 book ai didi

javascript - 如何以编程方式取消 AlertIOS

转载 作者:行者123 更新时间:2023-12-03 00:45:39 25 4
gpt4 key购买 nike

描述

我有一个带有条形码扫描仪的组件。条码扫描仪返回值后,会出现带提示的 AlertIOS,其中包含取消保存按钮。现在,一种选择是单击保存按钮将值发送到服务器。对于另一个选项,客户端希望使用音量减小按钮发送数据或使用音量增大按钮取消。

问题

现在我已经设置了音量降低按钮的确认,但我还想在按下任何按钮时关闭警报弹出窗口。

我的代码

警报:

showAlert(value) {
this.alert = AlertIOS.prompt(
`Gescannter Wert: ${value}`,
'Menge eingeben (Standartwert ist 1)',
[{
text: 'Cancel',
onPress: () => this.scanning = true,
style: 'cancel',
},
{
text: 'Save',
onPress: (input) => this.pushCodeData(value, input)
}],
'plain-text',
'1',
'number-pad',
);
}

用于体积变化检测:

        this.volumeListener = SystemSetting.addVolumeListener((data) => {
let volume = data.value.toFixed(1);
console.log(volume, this.VOLUME);
SystemSetting.setVolume(this.VOLUME);

if (volume < this.VOLUME && this.scanning === false) {
console.log("confirm")
this.pushCodeData(this.state.scannedValue, 1)

} else if (volume > this.VOLUME && this.scanning === false){
console.log("cancel")
this.scanning = true
}
});

发送数据的函数是this.pushCodeData(params...)

是否可以通过编程方式关闭警报提示?到目前为止我找不到任何答案。

最佳答案

尚无法以编程方式关闭警报。 https://github.com/facebook/react-native/issues/4928

你可以尝试一下。

How can I remove Alert prompts programmatically?

关于javascript - 如何以编程方式取消 AlertIOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53259728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com