ios - 使用sharedmanager后的警报

标签 ios objective-c cocoa-touch

这是我的代码

audioViewController *voiceRecorder = [audioViewController sharedManager];
[voiceRecorder stopRecording];
NSString *msg = [NSString stringWithFormat:@"Want to logout?"];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Info" 
                                                message:msg 
                                               delegate:self 
                                      cancelButtonTitle:@"No" 
                                      otherButtonTitles:@"Yes", nil];
alert.tag = 100;
[alert show];

我正在我的一个 View Controller 中调用sharedManager。问题是,我的alertview在sharedManager方法执行之前运行,如果你检查我的代码,我已经调用了“StopReording”方法,但是当我运行代码时,它在显示警报后起作用。任何人都知道,如何仅在方法返回某些内容后才显示警报。?

最佳答案

您似乎对方法运行顺序和警报呈现顺序感到困惑。这些方法必须按照代码指定的顺序运行。您在屏幕上看到的是 2 个警报,一个(停止)首先出现,另一个(注销)紧随其后出现。

通常,您不应同时显示 2 个警报。如果它们涉及不同的事物,当然不是。

呈现您的第一个警报,然后等待收到答案(使用委托(delegate)方法)。一旦您得到用户的回答,然后决定下一步做什么并显示第二个警报或继续执行其他操作。

关于ios - 使用sharedmanager后的警报,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17387065/

相关文章:

ios - DJI OSMO 相机获取图像失败

ios - 由于未捕获的异常 'NSInternalInconsistencyException' GLKView 而终止应用程序

iOS ABPersonViewController

ios - Uitableview Cell Animation like Secret App

objective-c - 底部的 UISplitView 和自定义工具栏

ios - UISearchBar 位于 UICollectionView 之上,如何让它仅与集合中的项目一起工作?

objective-c - 在 iOS 中手动更新界面方向

objective-c - UITableView 中分页实现的查询

ios - Segue 到 Storyboard 中的 Person ViewController

objective-c - UIAlertController 中的动态按钮 (iOS 8)