WKInterfaceMap on Apple Watch
-
Upload
yusuke-kita -
Category
Engineering
-
view
929 -
download
3
Transcript of WKInterfaceMap on Apple Watch
![Page 1: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/1.jpg)
WKInterfaceMap on Apple Watchtrippiece Inc.@kitasuke
![Page 2: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/2.jpg)
Restaurant finder appin Shibuya
![Page 3: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/3.jpg)
10 things you should know about watchkit
before you submitSee this one as well
![Page 4: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/4.jpg)
There are limitations on WKInterfaceMap
at this time
![Page 5: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/5.jpg)
Current limitations• Request location access on iPhone, not Apple Watch
• Not scrollable on map
• Not zoomable on map
• Not opening Apple's map app
• 5 annotations at maximum
![Page 6: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/6.jpg)
Location servicevar locationManager = CLLocationManager()
override init() { super.init()
locationManager.delegate = self if CLLocationManager.locationServicesEnabled() { switch CLLocationManager.authorizationStatus() { case .AuthorizedAlways, .AuthorizedWhenInUse: locationManager.startUpdatingLocation() } }}
func locationManager(manager: CLLocationManager!, didUpdateToLocation newLocation: CLLocation!, fromLocation oldLocation: CLLocation!) {
}
![Page 7: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/7.jpg)
Use Handoff in case it's not granted yet
override init() { let type = "com.example.com" let userInfo = ["actionID": 1] self.updateUserActivity(type, userInfo: userInfo, webpageURL: nil)}
![Page 8: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/8.jpg)
AnnotationNo annotation for current locationUse custom image instead
![Page 9: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/9.jpg)
CacheCache annotation imageslet image = UIImage()let device = WKInterfaceDevice.currentDevice()device.addCachedImage(image, name: "annotation")
self.mapView.addAnnotation(CLLocationCoordinate2DMake(0.0, 0.0)withImageNamed:"annotation"centerOffset:CGPointZero)
![Page 10: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/10.jpg)
RealmRealm is a replacement for SQLite & Core Data. It can save you thousands of lines of code & weeks of work, and lets you craft amazing new user experiences.
![Page 11: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/11.jpg)
Why Realm?
![Page 12: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/12.jpg)
Usage between iOS and WatchKit// Get the shared directory for the application grouplet id = "group.com.example.my-app"let fileManager = NSFileManager.defaultManager()let container = fileManager.containerURLForSecurityApplicationGroupIdentifier(id)
// Set the default realm path to a location in the shared containerlet fileName = "defualt.realm"if let realmURL = container?.URLByAppendingPathComponent(fileName) { RLMRealm.setDefaultRealmPath(realmURL.path)}
// Get location infolet restaurant = Restaurant.allObjects().firstObject() as! Restaurantlet coordinate = CLLocationCoordinate2DMake(restaurant.latitude, restaurant.longitude)
![Page 13: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/13.jpg)
App reviewWe found that the usefulness of your Apple Watch app is limited by the minimal features it includes. Specifically, your Apple Watch app only launches out to Maps.— From Apple
![Page 14: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/14.jpg)
There are tons of functions, but make it
simple
![Page 15: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/15.jpg)
![Page 16: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/16.jpg)
PagingMenuItem SegmentedControl
![Page 17: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/17.jpg)
Usagelet viewController = UIViewController()viewController.title = "Menu title"let viewControllers = [viewController]
let options = PagingMenuOptions()options.menuHeight = 50
let pagingMenuController = self.childViewControllers.first as! PagingMenuControllerpagingMenuController.setup(viewControllers: viewControllers, options: options)
![Page 18: WKInterfaceMap on Apple Watch](https://reader034.fdocuments.net/reader034/viewer/2022042507/55b6d3b4bb61eb93418b48b9/html5/thumbnails/18.jpg)
Welcome your feedbackhttps://github.com/kitasuke/PagingMenuController