Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.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
Ios MKMapView放置在UITableViewCell内时未显示位置_Ios_Objective C_Uitableview_Mkmapview - Fatal编程技术网

Ios MKMapView放置在UITableViewCell内时未显示位置

Ios MKMapView放置在UITableViewCell内时未显示位置,ios,objective-c,uitableview,mkmapview,Ios,Objective C,Uitableview,Mkmapview,以前,我在ViewController上有一个MKMapView,它将在给定位置显示一个圆覆盖(由ViewController属性的对象提供)。我重构了VC,现在我把这个映射的代码放在了cellForRowAtIndexPath中(基本上将viewDidLoad中的“self.mapView”替换为cellForRowAtIndexPath中的“cell.mapView”) 有了上面的代码,我可以看到整个美国的全景,没有覆盖 我不想显示用户的当前位置(尽管我可以通过在Interface Buil

以前,我在ViewController上有一个MKMapView,它将在给定位置显示一个圆覆盖(由ViewController属性的对象提供)。我重构了VC,现在我把这个映射的代码放在了cellForRowAtIndexPath中(基本上将viewDidLoad中的“self.mapView”替换为cellForRowAtIndexPath中的“cell.mapView”)

有了上面的代码,我可以看到整个美国的全景,没有覆盖

我不想显示用户的当前位置(尽管我可以通过在Interface Builder中勾选复选框来实现)。相反,我将传递一组坐标,这些坐标与保存在解析后端的对象(“self.item”)一起存储

我可以访问对象的所有其他属性,并且这段代码以前工作过(在上面提到的tableView之外),所以我认为这与tableViewCell本身有关。在TableViewCell上放置地图视图是否有问题

试试这个, 将委托添加到自定义单元格中,而不是视图控制器中

@interface MapTableViewCell : UITableViewCell
<MKMapViewDelegate>

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

@end

cell.mapView
是IBOutlet吗?如果是,请确保它已连接到xib中的MKMapView。在任何情况下,请确保
cell.mapView
不是
nil
@interface MapTableViewCell : UITableViewCell
<MKMapViewDelegate>

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

@end
// In cellForRowAtIndexPath set the delegate like:
cell.mapView.delegate = cell;