If you’re using UIAlertView and targeting your application for iOS 8.3 or higher, you’re probably aware that you’ll get a deprecated compiler warning.
The replacement for UIAlertView is actually UIAlertController. The most important thing you need to know is that UIAlertView could have been called anywhere.
Now you have to construct a UIAlertController and then present it from a controller. This is similarly how you would call any other presentation view controller.

Now presenting UIPopoverViewController has also been deprecated for a simpler and more consistent API. This migration is also rather easy.

UIAlertController

UIAlertController also can substitute UIActionSheet as well. When constructing it all you need to do is feed it the proper enum: either UIAlertControllerStyleAlert or UIAlertControllerStyleActionSheet. For Swift 3.0 you can feed it UIAlertControllerStyle.actionSheet or UIAlertControllerStyle.alert.

Objective-C

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
NSString *title = @"My Title";
NSString *message = @"This alert is a good thing for your health!";
UIAlertController *alertController = [UIAlertController alertControllerWithTitle: message:message preferredStyle:UIAlertControllerStyleAlert];

[controller addAction:[UIAlertAction actionWithTitle:@"Ok" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

}]];

[controller addAction:[UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) {

}]];

[self presentViewController:alertController animated:YES completion:^{
//do something
}]

Swift 3.0

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
let title = "My Title"
let message = "This alert is a good thing for your health!";
let alertController = UIAlertController(
title: title,
message: message,
preferredStyle: .AlertView)

let alertController = UIAlertController(
title: title,
message: message,
preferredStyle: .alert)

alertController.addAction(UIAlertAction(title: "Ok", style: .default, handler: { (action) in

})

alertController.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { (action) in

})

self.present(alertController, animated: true, completion: { _ in
//do something
})

UIPopoverViewController

Now that UIPopoverViewController is deprecated, you’re going simply present the controller but with some modified extended properties.

Objective-C

1
2
3
4
5
6
7
8
SomeViewController *someViewController = [[SomeViewController alloc] init];
someViewController.modalPresentationStyle = .popover
someViewController.popoverPresentationController.sourceView = someView
someViewController.popoverPresentationController.sourceRect = someViewRect

[self presentViewController:alertController animated:YES completion:^{
//do something
}]

Swift 3.0

1
2
3
4
5
6
7
8
let someViewController = UIViewController()
someViewController.modalPresentationStyle = .popover
someViewController.popoverPresentationController?.sourceView = someView
someViewController.popoverPresentationController?.sourceRect = someViewRect

present(someViewController, animated: true, completion: { _ in

})

#Conclusion

So as you can see, presenting another UIViewController even as an ActionSheet or Popover has become very consistent.