When we develop universal apps, we sometimes need to present modal view controllers (“dialogs”) to the user.
On the iPad the popover is very useful to this aim because the user does not loose the context while reading the content of the dialog or while filling some inputs inside it.
On the other side, the iPhone usually has not enough space to show a popover inside the parent (or “presenting”) view controller (however this is possible now in iOS8). So on the iPhone we may want to present the new view controller in a modal full screen mode.
In iOS8 the code to show a simple alert to the user is completely changed. UIAlertView is now deprecated:
The new class is UIAlertController and it is not complex to use (more in a minute). But we also want to support our iOS7 users, so wouldn’t it be nice to have a single class handling the different code? This is what we are going to create in this post.