Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/103.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从NIB加载/创建用于地理位置的视图-IOS和MapKit_Ios_Model View Controller_Geolocation_Mapkit - Fatal编程技术网

从NIB加载/创建用于地理位置的视图-IOS和MapKit

从NIB加载/创建用于地理位置的视图-IOS和MapKit,ios,model-view-controller,geolocation,mapkit,Ios,Model View Controller,Geolocation,Mapkit,我有两个类-MapView和MapController。其主要思想是使视图成为MVC模式中的共享对象 MapView在MapNib.xib中为MKMapView设置了IBOutlet“MapView” MapController包含引用类mapView的属性“mapView” 然后,我尝试从控制器设置MKMapView的一些属性,但它不会对此做出任何反应。例如,我在MapController中尝试: self.mapView.mapView.showUserLocation = YES; //

我有两个类-MapView和MapController。其主要思想是使视图成为MVC模式中的共享对象

  • MapView在MapNib.xib中为MKMapView设置了IBOutlet“MapView”
  • MapController包含引用类mapView的属性“mapView”
  • 然后,我尝试从控制器设置MKMapView的一些属性,但它不会对此做出任何反应。例如,我在MapController中尝试:

    self.mapView.mapView.showUserLocation = YES; // does not show blue point ...
    
    地图视图类:

    @interface MapView : UIViewController
    
    @property (nonatomic, retain) IBOutlet MKMapView *mapView;
    
    ...
    
    //UINib *view = [UINib nibWithNibName:@"MapView" bundle:nil];
    //[view instantiateWithOwner:self options:nil];
    
    @end
    
    MapController类:

    @interface MapController : UIViewController<
        CLLocationManagerDelegate, 
        MKMapViewDelegate> 
    
    @property (nonatomic, retain) MapModel *mapModel;
    @property (nonatomic, retain) MapView *mapView;
    
    ...
    
    - (void)viewDidLoad
    {
        [super viewDidLoad];
    
        self.mapView = [[[MapView alloc] init] autorelease];
        self.mapView.mapView.showsUserLocation = YES;
    
    } @end
    
    然后在控制器中:

    self.mapView.showUserLocation = YES; // now this shows blue dot ... why???
    

    谢谢,无需创建Art

    IBoutlet。NIB创建它们并将它们分配给您的变量,您正在通过分配和初始化新的mapview并将其保存到该变量来覆盖它

    这很有意义。。。虽然我不知道我到底在哪里启动了一个IBOutlet?我只分配了名为“MapView”的自定义类,它有我不接触的IBOutlet。。。还是我错了?你的意思是,如果我初始化我的类,这会导致为它的IBOutlet分配内存吗?
    self.mapView.showUserLocation = YES; // now this shows blue dot ... why???