0

独自のデリゲート内で UIAlertView を呼び出していますが、失敗しています。コードは簡単です:

@interface ViewController () <UIAlertViewDelegate>
@property (nonatomic, strong) UIAlertView *alertView;
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.alertView = [[UIAlertView alloc] initWithTitle:@"Howdy"
                                                message:@"Here's the alert"
                                               delegate:self
                                      cancelButtonTitle:@"Cancel"
                                      otherButtonTitles:@"OK", nil];
    [self.alertView show]; // this shows the 
}


- (void)alertView:(UIAlertView *)alertView didDismissWithButtonIndex:(NSInteger)buttonIndex
{
    if (buttonIndex == 1) {
        [self.alertView show]; // this does not show the alert again!
    }
}

@end

ただし、削除すると:

[self.alertView show] 

そしてそれを次のように置き換えます:

[self.alertView performSelector:@selector(show) withObject:nil afterDelay:0.01]

できます。

これは、私がデリゲート メソッド内にいるにもかかわらず、オリジナルUIAlertVIewが完全に却下されていないことを示しているようですalertView:didDismissWithButtonIndex:

これは機能していますが、正しくないようです。誰が私が間違っているのか教えてもらえますか?

4

1 に答える 1