【发布时间】:2009-07-06 23:01:02
【问题描述】:
在 tableview cellForRowAtIndexPath 中,我执行以下操作:
MapViewController *mapView = [[MapViewController alloc] initWithCoordinates:city.Latitude longitude:city.Longitude];
[cell addSubview:mapView.view];
//[mapView release]; -- will crash here
调用最后一行会产生此内存错误 EXC__BAD _ACCESS”。如何在不崩溃的情况下释放我分配的上述内存?
从上面看,cell 是一个 UITableViewCell。
MapViewController 是一个 UIViewController,它实现了 MKReverseGeocoderDelegate 和 MKMapViewDelegate。在 MapViewController 的 init 中,它分配了一个 MKMapView。在控制器的 viewDidLoad 中,它将 mapview 添加到 UIViewController 的视图中:
[self.view addSubview:mapView];
【问题讨论】:
标签: cocoa-touch uitableview iphone-sdk-3.0 uiviewcontroller