gpt4 book ai didi

iphone - 从未调用过 alertView didDismissWithButtonIndex

转载 作者:行者123 更新时间:2023-11-28 22:30:45 25 4
gpt4 key购买 nike

第一次发帖,如有不妥请见谅。

我见过几个与此类似的问题,但没有一个问题相同。我正在运行 IOS 6.1 和 Xcode 4.6。问题是永远不会调用 didDismiss,只会调用 willDismiss。我的代码连同日志输出在下面。有什么想法吗?

#import "MenkLabUIAlertTestViewController.h"

@interface MenkLabUIAlertTestViewController ()

@end

@implementation MenkLabUIAlertTestViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}

- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.


}
- (IBAction)test:(id)sender {
UIAlertView *av = [[UIAlertView alloc] initWithTitle:@"Encrypting File(s)" message:@"Please wait..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
// UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[av show];
[av dismissWithClickedButtonIndex:-1 animated:YES];
}

- (void) alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"willDISMIS");
}

- (void) alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"didDISMIS");
}


- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end

日志输出:

2013-07-08 17:27:04.055 testUIAlertView[10534:11303] 将关闭

这只是一个测试应用程序,但是,它与我当前应用程序中存在的问题完全相同。

提前致谢。一整天都在为这件事绞尽脑汁!

最佳答案

我认为这是您显示的事实的产物,然后立即以相同的方法关闭警报 View ——您永远不会在真实的应用程序中实际执行此操作。如果您为警报 View 创建一个属性,然后进行如下测试,它工作正常:

- (IBAction)test:(id)sender {
self.av = [[UIAlertView alloc] initWithTitle:@"Encrypting File(s)" message:@"Please wait..." delegate:self cancelButtonTitle:nil otherButtonTitles:nil, nil];
[self.av show];
[self performSelector:@selector(dismissAlertView) withObject:nil afterDelay:1];
}


-(void)dismissAlertView {
[self.av dismissWithClickedButtonIndex:-1 animated:YES];
}

- (void) alertView:(UIAlertView *)alertView willDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"willDISMIS");
}

- (void) alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex {
NSLog(@"didDISMIS");
}

关于iphone - 从未调用过 alertView didDismissWithButtonIndex,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17536328/

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