How to clear the cache of mkmapview

2019-02-20 08:57发布

In my app.I have a one textfield and one search button.when it user click on search button after fill up the address on textfield my app shows the result and place a pin on mapview. I am using google maps api for it. I have also added the functionality user can drag and drop the pin. when the user drag the pin and drop on another place.The previous pin should be removed.For removing that pin i am using [mapView removeAnnotation[mapView.annotations lastObject]];

but when i again search a new address which is already search.It again created a new pin. I know this is coming from cache of mkmapview. **Now how can i remove it(pin) from mkmapview

2条回答
混吃等死
2楼-- · 2019-02-20 09:12

Just to update, since I was looking for this. Seems a bit cleaner

[[NSURLCache sharedURLCache] removeAllCachedResponses];
查看更多
做自己的国王
3楼-- · 2019-02-20 09:30

Try This

NSURLCache *sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:0 diskCapacity:0 diskPath:nil]; 

[NSURLCache setSharedURLCache:sharedCache];
 [sharedCache release];
查看更多
登录 后发表回答