0

This is my code

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];

I am calling sharedManager in one of my view controller. The problem is, my alertview runs before sharedManager method executes, if you check my code, i have called "StopReording" method, but when i run the code, it works after showing alert. Anyone has idea, how do I show alert only after the method returns something.?

4

1 回答 1

1

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

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

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

于 2013-06-30T07:56:52.263 回答