0

I've implemented a Today widget for my application.

The mkmapView work fine in two situation: 1. Xcode simulator 2. device run with Xcode

but the mapView only show background color and user's Location marker when I run the widget by device itself.

Does anybody know why? How to resolve it?

thx!

YenCheng
  • 13
  • 2

2 Answers2

2

Straight from the Apple documentation

Make sure that the Today extension point is appropriate for the functionality you want to provide. The best widgets give users quick updates or enable very simple tasks. If you want to create an app extension that enables a multistep task or helps users perform a lengthy task, such as uploading or downloading content, the Today extension point is not the right choice.

MKMapView required constantly changes when you span or zoom and delegates are called on respected manner.

So this is one of the cause that you don't see any more updates while you are adding a map in today widget.

Kampai
  • 22,848
  • 21
  • 95
  • 95
  • because I saw an app has map function https://itunes.apple.com/tw/app/pinow/id937720782?mt=8 – YenCheng Jan 09 '15 at 07:52
  • This may be a screen shot from mapView. Not whole map can be render there. `MKMapView` does provide the facility to take a snap shot of your map from certain points. – Kampai Jan 09 '15 at 07:54
1

You can use MKMapSnapshotter to take a snapshot of the map but I was still having some memory and autolayout (why!?!?) issues using this in a today extension. Our not-so-great-but-works solution is to use our app's background location fetching mechanism and a shared container to store the NSData from the MKMapSnapshotter. Then in the today extension, doing as little work as possible, just reading the NSData out of the container and displaying it with an UIImageView.

zackola
  • 116
  • 1
  • 2