rholmes
rholmes

Reputation: 4174

Context Menu IBActions not firing in Xcode 7 Beta

I originally found this problem in the Xcode beta when I converted an existing iOS app/ WatchKit app from Swift 1.x/WatchKit 1.x to Swift 2.0 / WatchKit 2.0 (beta). The general problem: When running the WatchKit App in the simulator the IBAction functions don't get called for MenuItems. Just had the problem on Xcode 7 beta 4.

Steps to Reproduce:

  1. Create a new "iOS app with WatchKit app" project in Xcode 7b3. Enter the companion view mode for the WatchKit App's Interface.storyboard.
  2. You should see the storyboard alongside the InterfaceController.swift file implementing the WKInterfaceController.
  3. Drag a "Menu" onto the Interface Controller in the storyboard. There should already be one menu item there.
  4. Add another menu item.
  5. Set the Title of the first item to "Menu A" and set its Image to "Accept".
  6. Do the same for the second item but call it "Menu B".
  7. Control-drag from each menu item to the InterfaceController.swift and name the corresponding IBActions to something indicating which manu there from.
  8. Add print statements to the willActivate functions as well as each IBAction.
  9. Run in the debugger using the simulators.
  10. After it finally connects (after a few false starts), select the menu items a few times in the simulator.

Expected Results: I would expect the IBActions to get called.

Actual Results: No IBAction breakpoints were hit nor were IBAction print() statements activated.

Version: Version 7.0 beta 3 (7A152u)

I searched the forums at developer.apple.com as well as StackOverflow and found no mention of this problem, nor was it in the release notes.

Upvotes: 1

Views: 634

Answers (1)

rholmes
rholmes

Reputation: 4174

Well, it turns out that the "problem" has a "workaround". First, I'm running on a 2010 MacBook Pro. In Xcode 6.x, the "force touch" in the simulator is done using a sustained "true click" (even if you have single-tap click enabled for the track-pad, to get force touch you must actually activate the touch pad press). Shallow touch can be initiated by a tap or a short "true click" on the trackpad.

On the Xcode 7 betas, the behavior of the watch simulator no longer follows this paradigm; presumably because they take advantage of force touch on the newer Mac laptops. Instead, to test the menus on the new Xcode 7 beta simulator, you must perform the following actions on a non-force-touch Mac:

  1. Switch the Watch simulator force touch to "deep": Hardware => Force Touch Pressure => Deep Press (cmd-shift-2).
  2. "True click" the interface view to bring up the context menu view
  3. Switch the Watch simulator force touch to "shallow": Hardware => Force Touch Pressure => Shallow Press (cmd-shift-1).
  4. "True click" on the menu to select it.

Note that single-tap touching doesn't work for any of these actions, even if enabled in the trackpad preferences. Also note that the visual feedback when you inadvertently use a "Deep Press" to attempt to select a menu; it looks almost like you've selected it!

Upvotes: 5

Related Questions