gpt4 book ai didi

ios - 让UIAccessibilityPostNotification在UIAlertView中完成

转载 作者:行者123 更新时间:2023-11-29 02:47:02 24 4
gpt4 key购买 nike

我想通过 UIAlertView 中的 UIAccessibilityPostNotification 发布消息。我的问题是警报 View 关闭并且消息突然停止(至少这是我的分析),几乎没有说出两个词。有没有办法让通知完成?我的代码如下:

//Function which calls UIAlertView
-(IBAction)foo:(id)sender
{
UIAlertView* myAlert = [[UIAlertView alloc] initWithTitle:@"Select to get more information"
message:@""
delegate:self
cancelButtonTitle:@"Cancel"
otherButtonTitles:@"a",@"b",@"c", nil];
myAlert.tag=2;
[myAlert show];

//Code comes here immediately, even if I don't select anything on alertView.
NSLog(@"Does it come here? Yes!");
}

我的警报 View :

if ([alertView tag]==2)
{
//Some code
NSString* message = @"Long message";
if (UIAccessibilityIsVoiceOverRunning())
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, message);
else
NSLog(@"Voice-over is not running.");
}

我也准备改变我的代码逻辑。我尝试过在我们在警报 View 上选择一个选项后代码是否继续,以便我可以将 message 变量设置为全局变量并通过 foo 函数发布通知。它没有按预期发生。程序在 alertView 关闭后停止。

是否存在任何解决方法?我是一名业余 iOS 程序员,所以一些代码和解释会有所帮助。

附言如果有的话,我什至可以使用警报 View 以外的东西。我只想有一个弹出窗口和一些按钮作为选择。

最佳答案

IMO,您应该使用 UIView 创建自定义弹出窗口以向最终用户显示选项。然后首先显示为用户提供选项的弹出窗口,一旦用户选择其中一个(或在选择其中一个后点击按钮),调用 UIAlertView 以显示相关消息。

希望这样你的问题会得到解决。

关于ios - 让UIAccessibilityPostNotification在UIAlertView中完成,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24988278/

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