I have a very simple cordova app that is an extension of the default cordova 'device ready' template. It has one button with a simple click event attached.
var app = {
// Application Constructor
initialize: function() {
this.bindEvents();
},
// Bind Event Listeners
//
// Bind any events that are required on startup. Common events are:
// 'load', 'deviceready', 'offline', and 'online'.
bindEvents: function() {
document.addEventListener('deviceready', this.onDeviceReady, false);
},
// deviceready Event Handler
//
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
onDeviceReady: function() {
app.receivedEvent('deviceready');
},
// Update DOM on a Received Event
receivedEvent: function(id) {
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');
listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');
console.log('Received Event: ' + id);
}
};
app.initialize();
console.log('ready to test button');
document.getElementById("testBttn").addEventListener("click", function (){
console.log('button was pressed!');
});
The problem I am facing is that the button is completely unresponsive to any click (touch gesture) when running on the simulator
The button works fine and outputs to console when run in a browser
When I run the app through XCode on the simulator instead of the CLI I get the same result although I get the following output as soon as I click anywhere on the simulator screen.
This output offers little insight but may indicate an obvious issue. I have never had this output when building native ios applications.
Any help appreciated.
Edit: I am using XCode 8.0
I mention this as it appears this kind of console output is quite common in XCode 8 when building ios 10 apps. It seems from what I can find that this console output is trivial and is nothing out of the ordinary..
解决方案
I have found the same thing happening to me today all of a sudden. The only solution that I have found isn't really a solution at all but when I switch to a different app and then switch back to my app suddenly the touch events all start working again. But a freshly opened app is completely unresponsive. So not exactly a solution but see if you experience the same behaviour.