gpt4 book ai didi

iphone - 如果操作从 UIAlertView 委托(delegate)启动,则 UIViewController 在从导航 Controller 弹出后不会被释放

转载 作者:行者123 更新时间:2023-12-03 21:20:11 25 4
gpt4 key购买 nike

请您看一下这段代码:

/* This app is a game, the user can click an "abort" button anytime,
* and he/she is therefore asked for confirmation ("really abort game?")
*/
- (IBAction)btnAbortClicked:(id)sender {
UIAlertView *alert = [[UIAlertView alloc] init];
[alert setMessage:@"Really abort game?"];
[alert setDelegate:self];
[alert addButtonWithTitle:@"Yes"];
[alert addButtonWithTitle:@"No"];
[alert show];
[alert release];
}

/* Delegate method (I don't like it, I wish I had modal blocking windows) */
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex {
if (buttonIndex == 0)
[self quitGame];
}

/* pop the view controller */
- (void)quitGame {
[self.navigationController popToRootViewControllerAnimated:YES];
}

问题很简单 - 但显然不足以让我解决。 UIViewController 被弹出,但没有被释放。这个问题与 UIAlertView 严格相关,因为如果我只是从 btnAbortClicked: 调用 quitGame, View Controller 就会弹出并立即释放。

相反,似乎有一些神秘的实体保留了它。

你能帮我吗?提前致谢。

最佳答案

嗯,我认为当调用 clickedButtonAtIndex 时你仍然在alertView中。我建议改为使用alertView:disDismissWithButtonIndex,以便在alertview 消失后调用您。

关于iphone - 如果操作从 UIAlertView 委托(delegate)启动,则 UIViewController 在从导航 Controller 弹出后不会被释放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5507451/

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