我需要在UITableViewCell中加载地图。我在UIViewController中使用了tableview来显示地图。我们可以作为pushviewcontroller导航到viewcontroller。首先它需要正常的内存但是当我弹出viewcontroller并转到这个viewcontroller时,内存增加了一定的数量。只要我按下并弹出viewcontroller,这个过程就会继续。
UITableViewCell中的代码:
class LocationCell:UITableViewCell {
@IBOutlet weak var mkmapView: MKMapView!
override func awakeFromNib() {
super.awakeFromNib()
mkmapView.layer.cornerRadius = 10
}
}
UIViewController中的代码
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("LocationCell") as! LocationCell
let center = CLLocationCoordinate2D(latitude: 48.8755786, longitude: 2.3162554)
let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.01, longitudeDelta: 0.01))
cell.mkmapView.setRegion(region, animated: true)
return cell
}