A
A
Anton Parfenov2016-02-11 12:17:28
iOS
Anton Parfenov, 2016-02-11 12:17:28

Display UIAlertController and hide it programmatically, how?

Guys, how to display UIAlertController and hide it on request?
I want to just block the screen while the data is loading, for example, in a tableview and show an alert with the text "loading" for this time. I
show it like this:
https://yadi.sk/i/JFsuR9FmoeftN
Code:

func showIndicator() -> UIAlertController {
        let pending = UIAlertController(title: "Загрузка...", message: nil, preferredStyle: .Alert)
        self.presentViewController(pending, animated: true, completion: nil)
        return pending
    }

I call like this:
showIndicator()
it doesn’t work like that to kill, or rather it’s not quite suitable (
self.dismissViewControllerAnimated(false, completion: nil)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
An, 2016-02-12
@goldbest

You need to remember the displayed alert (pending which is preferably weak) and where you will close the
pending?.presentingViewController?. dismiss... And so on. Usually this is done in some kind of alert manager, router, or whatever.
Another option is to look for ready-made solutions (yes, yes, they are). And then an alert with the inscription loading, somehow this is wrong ...
Here is the first one that came prettier
https://github.com/jasperblues/ICLoader

A
Anton Marunko, 2016-02-11
@Antonio-banderas

Why doesn't it fit?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question