使用ObjectiveC从另一个ViewController刷新位置MapView

我是移动应用程序开发的新手,目前我正在制作一个包含ViewController中的MapView和另一个带有SerchBar的TableView的MapView的应用程序。在TableView中,我有一个位置列表以及它们各自的经度和纬度,当我单击表视图中的一个项目时,它会将我发送到另一个ViewController中MapView中的位置,并传递经度和纬度。

我正在通过以下方式进行操作:

FILE SearchViewController.m

#import "mapViewController.h"
mapViewController *mapView = [self.storyboard instantiateViewControllerWithIdentifier:@"MapViewController"];
[mapView goToLocation:strLongitudLoc reclati:strLatitudLoc];

FILE mapViewCoontroller.m

@property (strong,nonatomic) IBOutlet MKMapView *mapView;

-(void)goToLocation:(NSString *)reclong reclati:(NSString *)reclati {
        CLLocationCoordinate2D coord = {.latitude = [reclati floatvalue],.longitude = [reclong floatvalue]};
        MKCoordinateSpan span = {.latitudeDelta = 0.050f,.longitudeDelta = 0.050f};
        MKCoordinateRegion region = {coord,span};
        [mapView setRegion:region];
}

当您调用mapViewController函数时,mapView对象为Nil,并且在Map上没有任何活动。 如果我在mapViewController上进行一些活动,则可以毫无问题地进行,但如果我想从另一个searchViewController上在地图上进行一些活动,则它什么也不做。 谁能帮助我?

hxj752367319 回答:使用ObjectiveC从另一个ViewController刷新位置MapView

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2541269.html

大家都在问