Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialTim Hughes
12,839 PointsHey, any idea when this content is likely to be updated for IOS8 or a workaround implemented? :)
Some elements in IOS8 are now deprecated as stated in the IOS developer library
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIAlertView_Class/index.html
1 Answer
David Hughes
6,851 PointsThe replacement is UIAlertController and UIAlertAction in iOS 8.
This will only work in iOS 8 though so if you want backwards compatibility with iOS 7 or lower then you need to continue to use UIAlertView.
In Objective C you would do something like:
UIAlertController* alert = [UIAlertController alertControllerWithTitle:@"My Alert"
message:@"This is an alert."
preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction* defaultAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault
handler:^(UIAlertAction * action) {}];
[self presentViewController:alert animated:YES completion:nil];
And in Swift.
let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert)
let action = UIAlertAction(title: "OK", style: .Default,
handler: { action in
self.startNewRound()
self.updateLabels()
})
alert.addAction(action)
self.presentViewController(alert, animated: true, completion: nil)
Some good examples here: http://hayageek.com/uialertcontroller-example-ios/