2014-12-06 12 views
5

Wyświetlam kontroler UIAlertController podczas pobierania obrazu. Po zakończeniu pobierania chcę nacisnąć kontroler widoku. Mam błąd w konsoli, bo nie odwołuje powiadomienie Kontroler:Jak zamknąć kontroler UIAlertController bez żadnych działań w SWIFT?

pushViewController:animated: called on <UINavigationController 0x7fb190c6ee00> while an existing transition or presentation is occurring; the navigation stack will not be updated. 

w moim głównym kontrolerem widok, gdy pobieranie zostanie zakończone, wciskam inny pogląd:

override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { 

    //.... 

    var alert = UIAlertController(title: "Alert", message: text, preferredStyle: UIAlertControllerStyle.Alert) 
    self.presentViewController(alert, animated: true, completion: nil) 


    dispatch_async(dispatch_get_main_queue(), { 
     if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) { 
       self.performSegueWithIdentifier("postview", sender: self) 

     } 
    }) 
} 

I próbowałem wit dismissViewControllerAnimated ale mam dokładnie ten sam błąd:

dispatch_async(dispatch_get_main_queue(), { 
      if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) { 
        alert.dismissViewControllerAnimated(true, completion: nil) 
        self.performSegueWithIdentifier("postview", sender: self) 

      } 
     }) 

Odpowiedz

9

nie należy zadzwonić performSegueWithIdentifier zanim poprzedni kontroler pogląd został odrzucony. Do czasu to poprawnie, zrób to z obsługi realizacji:

dispatch_async(dispatch_get_main_queue(), { 
    if let cellToUpdate = tableView.cellForRowAtIndexPath(indexPath) { 
     alert.dismissViewControllerAnimated(true, completion: { 
      self.performSegueWithIdentifier("postview", sender: self) 
     }) 
    } 
}) 

Teraz wezwanie do wykonania segue nie rozpocznie, dopóki odwoływanie się skończy, zapobiegając błąd, który widzisz.

+0

Działa! dzięki ! – cmii

+0

Mam ten sam problem, @ dasblinkenlight.Can możesz mi pomóc? Oto mój link: http://stackoverflow.com/questions/30840235/console-warning-in-my-custom-alert-controller- który- powiedział-to-był-próbować-by-prese –

Powiązane problemy