wkinterfacemap on apple watch
TRANSCRIPT
WKInterfaceMap on Apple Watchtrippiece Inc.@kitasuke
Restaurant finder appin Shibuya
10 things you should know about watchkit
before you submitSee this one as well
There are limitations on WKInterfaceMap
at this time
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
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!) {
}
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)}
AnnotationNo annotation for current locationUse custom image instead
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)
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.
Why Realm?
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)
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
There are tons of functions, but make it
simple
PagingMenuItem SegmentedControl
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)
Welcome your feedbackhttps://github.com/kitasuke/PagingMenuController