Touch detection doesn't work on simulator for

2019-07-14 02:26发布

问题:

I've updated Xcode to Xcode 7. Then my Swift project to Swift 2. At last I removed removed all warnings.

First scene display few SKLabel and few SKSpriteNode.

Using iOS Simulator, touch detection doesn't work under iOS 9 but is ok on iOS 8. A breakpoint put ontouchesBeganmethod show this method is not called.

override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {

  // Breakpoint is set here
}

EDIT

Removing these messages does not solve anything.

Console display following warning 4 times, on iOS 9 only:

Error loading /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib:  dlopen(/System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib, 262): no suitable image found.  Did find:
    /System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin/Contents/MacOS/IOHIDLib: mach-o, but not built for iOS simulator

Cannot find function pointer IOHIDLibFactory for factory 13AA9C44-6F1B-11D4-907C-0005028F18D5 in CFBundle/CFPlugIn 0x7ba430f0 </System/Library/Extensions/IOHIDFamily.kext/Contents/PlugIns/IOHIDLib.plugin> (bundle, not loaded)

回答1:

Ok, problem solved!

On StoryBoard, userInteractionEnabled property on the main Viewof the initial view controller was set to "NO". Changed it to "YES" solve the problem.

This is weird because everything worked fine on iOS 8.



回答2:

I had the exact same problem on the simulator running iOS 9.0, and the issue turned out to be the language settings. I am posting my findings, so it can help anyone running into the same problem.

The simulator stops detecting touches if the region is set to India and Language to "English - India". To resolve the issue I reset the simulator and only changed the region to India, as my app functionality depends on the region. On retaining the language to "English - USA" the problem is not seen.

I am not sure what other language or region/language combinations can cause this issue. Hope this helps someone.