I have a UIAlertView that is triggered via a UIButton.
The UIAlertView displays two buttons, "Open Email" and "Cancel".
"Cancel" removes the UIAlert from the view. I'm trying to make it so when the user taps "Open Email", their device opens the default email application's compose screen, with an email address already in the "sender" section.
Using Swift 3.
Thanks!
import UIKit
import Kingfisher
class SettingsViewController: UIViewController {
@IBAction func copyrightInfo(_ sender: Any) {
let alert = UIAlertController(title: "Copyright Info", message: "text", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "I understand", style: UIAlertActionStyle.default, handler: nil))
self.present(alert, animated: true, completion: nil)
}
@IBAction func helpfeedbackAlert(_ sender: Any) {
let alertController = UIAlertController(title: "Help & Feedback", message: "text", preferredStyle: .alert)
let cancel = UIAlertAction(title: "Cancel", style: .destructive, handler: nil)
let openEmail = UIAlertAction(title: "Open Email", style: .default, handler: nil)
alertController.addAction(openEmail)
alertController.addAction(cancel)
self.present(alertController, animated: true, completion: nil)
}
@IBAction func clearCache(_ sender: Any) {
// SDImageCache.shared().clearMemory()
// SDImageCache.shared().clearDisk()
// Clear memory cache right away.
ImageCache.default.clearMemoryCache()
// Clear disk cache. This is an async operation.
ImageCache.default.clearDiskCache()
}
@IBAction func rateApp(_ sender: Any) {
if let url = URL(string: "https://www.google.com") {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:]) {
boolean in
// do something with the boolean
}
} else {
// Fallback on earlier versions
}
}
}
@IBAction func purchasePhotos(_ sender: Any) {
if let url = URL(string: "https://google.com") {
if #available(iOS 10.0, *) {
UIApplication.shared.open(url, options: [:]) {
boolean in
// do something with the boolean
}
} else {
// Fallback on earlier versions
}
}
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override var prefersStatusBarHidden: Bool {
get {
return true
}
}
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}