Skip to content

Instantly share code, notes, and snippets.

@marianomike
Created January 28, 2017 01:00
Show Gist options
  • Save marianomike/a23c824b7aabf545da5cfbfd7564d250 to your computer and use it in GitHub Desktop.
Save marianomike/a23c824b7aabf545da5cfbfd7564d250 to your computer and use it in GitHub Desktop.
import UIKit
import MapKit
import CoreLocation
class ViewController: UIViewController, UITextFieldDelegate, CLLocationManagerDelegate, MKMapViewDelegate {
// reference the user input field
@IBOutlet weak var inputText: UITextField!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
inputText.delegate = self
}
func textFieldShouldReturn(_ textField: UITextField) -> Bool {
// Hide the keyboard.
textField.resignFirstResponder()
return true
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func unwindToMenu(segue: UIStoryboardSegue) {}
// pass the value of the input throught the segue
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "showSecondViewController" {
let secondViewController = segue.destination as? SecondViewController
secondViewController?.userText = inputText.text
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment