watchkit

TouchEvents in watchOS 3 SpriteKit?

北战南征 提交于 2019-12-05 16:03:08
When using SpriteKit in watchOS 3, how do you handle the touch events? I am porting the SpriteKit games from iOS and the codes below won't work. Or you have to control the WKInterfaceController somehow? override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesCancelled(_ touches: Set<UITouch>, with event: UIEvent?) {} override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {} After a lot of frustration with the same issue, I wound up using gesture recognizers,

How to hide the back button from the status bar on the Apple Watch?

不问归期 提交于 2019-12-05 14:57:09
I want to hide the back button from my Apple Watch app from the status bar. I used the programmable segue to navigate. But I want to to hide/disable the back button. Is it possible? infinite-loop This is how you do it: WKInterfaceController.reloadRootControllersWithNames( ["myInterfaceController"], contexts: [] ) Where myInterfaceController is the identifier of the destination Interface Controller. Thanks to Harvant for the pointer. If you check the docs for WKInterfaceController , you'll see there's no API to accomplish what you're looking for: https://developer.apple.com/library/prerelease

How to share data between iPhone and Apple Watch using groups?

北城以北 提交于 2019-12-05 14:31:58
i am new to Watchkit development and unable to find solution to share data between iPhone and iWatch, please help me i am looking to share data using groups. Aadil Keshwani We can pass the data between iPhone & iWatch using groups. Basically iWatch can not do any processing and we need to share the data. We can share data using the NSUserDefaults . But for that you need to enable Appp Groups from capabilities section in both your project target and your iwatch app target, as showed below Below is the sample code to achieve that. In your viewController or appDelegate file add following code

Cannot decode object of class Employee for key (NS.object.0); the class may be defined in source code or a library that is not linked

喜欢而已 提交于 2019-12-05 14:01:54
问题 Im trying to pass an array of 'Employee' objects iPhone to Apple Watch by serializing the array : NSData *encodedObject = [NSKeyedArchiver archivedDataWithRootObject:employees]; and unserializing it as on the Watch side: NSMutableArray *employees = [NSKeyedUnarchiver unarchiveObjectWithData:encodedObject]; This is the 'Employee' class: @interface Employee : NSManagedObject @property (nonatomic, retain) NSNumber * employeeID; @property (nonatomic, retain) NSString * name; @property (nonatomic,

WatchOS Unit Testing

血红的双手。 提交于 2019-12-05 11:39:43
问题 I am building an app for Apple Watch and want to write a simple unit test. I looked around and didn't find a single way to add a unit testing bundle for watchOS code. Xcode supports unit tests for iOS, macOS and even tvOS but not for watchOS. Has anyone ever done it and if yes what is the trick? 回答1: No, watchOS does not currently (as of watchOS 3) support unit or UI testing. What you can do is cross-compile non-watchOS-specific code to a shared library, then unit test that on another

How can I avoid the error “Error Launching 'AppName' WatchKit Extension” when trying to build and run a WatchKit Extension on an actual Apple Watch?

风流意气都作罢 提交于 2019-12-05 07:53:10
When I try to build and run a WatchKit extension on my real Apple Watch, I sometimes get the following error message: I've tried to build the parent application for the iPhone and then again for my WatchKit app but I still get the error message. Does anyone know what causes this error message and how to deal with it? This seems to happen when it takes a long time to install the WatchKit App on the actual watch and Xcode times out waiting for the process to start due to the long install time. It can take a long time for two reasons: It sometimes takes a while for the Watch to "notice" the App

WatchKit Notification Sash Color

不问归期 提交于 2019-12-05 06:57:56
I've set my notification sash color in storyboard and it works fine in the simulator, but it shows up as gray on my watch. Does anyone know if this is a known issue or do you need to do something at runtime on a real device to show the color properly? The sash color is set for the WKNotificationCategory in the storyboard, which has a name. (In your screenshot "myCategory"). Then, for the correct sash color to appear on the real device, the push notification needs to have the matching category name when you send it. UILocalNotification *notification = [[UILocalNotification alloc] init]; if

WKInterfaceButton event handling in WKInterfaceTable

久未见 提交于 2019-12-05 04:48:08
问题 I have a WKInterfaceTable table view with a WKInterfaceButton . How can I add a target action to the button from the table view. As there is no tag property I am not able to handle it. 回答1: If your WKInterfaceButton is contained within a row controller, here is one method to determine which row's button was tapped: Add your WKInterfaceButton to the row controller and use interface builder to connect the button's action to your row controller class Add a property to your row controller that

Launch Watch App into middle view

大憨熊 提交于 2019-12-05 03:30:32
Basically, my app is laid out in the page format and I would like it to launch into the middle of the three pages. There is no way of setting a previous page segue, so I have been trying to do it in code. I have the main view set to the first view, and I have tried a variety of methods to segue to the middle view as soon as the app is launched. Here is the two ways I tried: if segueCheck == true { self.pushControllerWithName("budget", context: self) self.presentControllerWithName("budget", context: self) segueCheck = false } The first presents the view, but as a completely separate view, and

Can a real iOS device and Watch Simulator communicate for Testing purposes

走远了吗. 提交于 2019-12-05 03:14:06
I want to create a watch app for an existing iOS app. But I am in a situation that i don't own a apple watch and my existing iOS app will run only on real devices not on simulator. Is it possible to run the app on the iphone device and test my watch app in the watch simulator? Dmytro Hutsuliak Pairing a real iPhone and a Watch simulator is not possible at least at the moment. I make this conclusion because of 3 reasons: A Watch simulator automatically pairs to an iPhone simulator during the installation process. It is not possible to unpair a Watch simulator from the interface at all.