IBOutlet does not display its value in UI

后端 未结 2 1069
离开以前
离开以前 2021-01-26 00:32

I am building an iOS app using storyboards.I have implemented google maps in my app using swift and rest of the code is in objective C.

My scenario:

1.As shown

2条回答
  •  臣服心动
    2021-01-26 00:38

    You shouldn't use a custom segue to return to your first view controller. Segues always create a new instance of a view controller (unless you use an unwind segue). In your first view controller, add this method:

    - (IBAction)backFromMapView:(UIStoryboardSegue *)segue
    {
        NSLog(@"and we are back");
        MapViewController* mvc = (MapViewController *)segue.sourceViewController;
        NSLog(@"location %@", mvc.addressLabel.text);
    }
    

    Don't forget to #import -Swift.h so that Host.m will know about MapViewController.

    Then you'd control drag from the Done button in your Map View Controller to the orange exit icon in the bar above the view controller in the Storyboard. In the pop up, you'd select backFromMapView and voila, you're done.

    enter image description here

提交回复
热议问题