IBOutlet does not display its value in UI

泄露秘密 提交于 2019-12-02 11:44:11

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.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!