IBOutlet does not display its value in UI

后端 未结 2 1070
离开以前
离开以前 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 <YourProjectName>-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

    0 讨论(0)
  • 2021-01-26 00:40

    Try storing the location as a NSString strong property of your Host view controller OR Post a notification to your host view from Maps And in the viewWillAppear of the Host, First- NSLog the NSString and Second- assign this string to the label as text

    0 讨论(0)
提交回复
热议问题