I have a few moving parts in this one that I can\'t seem to stitch together, hopefully it is pretty straightforward.
Previous questions don\'t use a subclass and in
It seems that you're very close. In calloutAccessoryControlTapped
, you're get getting the place name and info. I'm assuming that's what you want to pass to the second view controller, so go ahead and do so before you show
it:
func mapView(_ mapView: MKMapView, annotationView view: MKAnnotationView, calloutAccessoryControlTapped control: UIControl) {
let capital = view.annotation as! Capital
let placeName = capital.title
let placeInfo = capital.info
let secondViewController = sUIKeyInputUpArrowtoryboard!.instantiateViewController(withIdentifier: "SecondViewController") // I'm not sure why you're not just doing `storyboard.instantiateViewController(...); do you really have multiple storyboards floating around?
secondViewController.placeName = placeName
secondViewController.placeInfo = placeInfo
show(secondViewController, sender: self)
}
That presumes, of course, that your second view controller is has those placeName
and placeInfo
properties, e.g.
class SecondViewController {
var placeName: String!
var placeInfo: String!
override func viewDidLoad() {
// use placeName and placeInfo to populate UI controls as necessary
}
}
I confess, though, that your question has a ton of unrelated code that's hard to make sense of, so it's not clear precisely what you need to do. But the idea is clear, that calloutAccessoryControlTapped
should
show
it; and Note, calloutAccessoryControlTapped
in the first view controller cannot update the UI controls in the second view controller directly (since the controls for that view controller have not yet been hooked up to the outlets in the storyboard), but rather just passes whatever data that second view controller needs. Then that second view controller will configure its controls in its viewDidLoad
.