Pregunta

I have an app where I am using DTAlertView & KGModal.

All is working perfectly. The only problem comes when I show DTAlertView over KGModal.

Let me explain working scenario.

  1. Click button and show modal
  2. Modal comes
  3. Tap outside of modal to dismiss
  4. Click again button to show modal.
  5. Modal comes

Below is the scenario which is not working

  1. Click button and show modal
  2. Modal comes
  3. Click button that in inside modal to show alertview.
  4. alertview comes
  5. click dismiss button to dismiss alertview
  6. alertview get dismissed
  7. Tap outside of modal to dismiss
  8. Click again button to show modal.
  9. Nothing comes (Here is the problem. Now the whole view is un-responsive)

Any idea what is going on?

Below is the link for sample download of project.

Sample Project

Code I have is as below.

- (IBAction)showModal:(id)sender {
    UIView *contentView  = [[UIView alloc] initWithFrame:CGRectMake(10, 100, 300, 280)];
    contentView.backgroundColor = [UIColor blackColor];

    UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    [button addTarget:self
               action:@selector(bringAlertBox)
     forControlEvents:UIControlEventTouchUpInside];
    [button setTitle:@"Show Alert" forState:UIControlStateNormal];
    button.frame = CGRectMake(0, 200, 300, 40.0);
    button.backgroundColor = [UIColor whiteColor];
    button.titleLabel.textColor = [UIColor blackColor];
    [contentView addSubview:button];

    [[KGModal sharedInstance] showWithContentView:contentView andAnimated:YES];
}

-(void) bringAlertBox {
    NSLog(@"bringAlertBox");
    DTAlertView *myAl = [DTAlertView alertViewWithTitle:@"WOW Alert" message:@"I like this alertview...." delegate:nil cancelButtonTitle:@"Dismiss" positiveButtonTitle:nil];
    [myAl setDismissAnimationWhenButtonClicked:DTAlertViewAnimationSlideTop];
    [myAl showWithAnimation:DTAlertViewAnimationSlideBottom];
}
¿Fue útil?

Solución

Not sure what was the problem, however when I hide below line in DTAlertView.m, problem is solved.

previousKeyWindow = DTRetain([[UIApplication sharedApplication] keyWindow]);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top