[TIMOB-23915] Hyperloop - iOS: Touch event properties and methods are undefined
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Critical |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2017-02-08T11:25:31.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop, iOS |
Labels | Hyperloop |
Reporter | Brian García |
Assignee | Jan Vennemann |
Created | 2016-09-16T09:05:33.000+0000 |
Updated | 2017-03-24T18:35:47.000+0000 |
Description
Trying to get lastPoint touched in screen return
JS exception encountered calling callback: undefined is not a function (evaluating 'UITouch.prototype.locationInView($.win)')
code to reproduce:
it assumes there is a win defined in xml.
var UIView = require('UIKit/UIView');
var DrawView = Hyperloop.defineClass('DrawView', 'UIView');
DrawView.addMethod({
selector : 'touchesBegan:withEvent:',
instance : true,
arguments : ['NSSet', 'UIEvent'],
callback : function(touches, event) {
var touch = touches.anyObject();
var lastPoint = touch.locationInView($.win);
console.log(lastPoint);
}
});
var drawSurface = DrawView.alloc().initWithFrame(50, 0, 350, 350);
drawSurface.backgroundColor = UIColor.yellowColor();
$.win.add(drawSurface);
You are passing a Ti.UI.Window to a native API, that won't work:
Instead, you may try to cast it to a UIView, using
UIView.cast($.win)
Same result with casting:
Then I guess
touch
is already null before. Try:instead.
touch returns a valid object:
any way touches.allObjects[0]; returns null
Ok, so it's really only about the
locationInView
method then. I also noticed that the log of the object returnslocation in view: {149.5, 225.5}
so at least something is there. I will move to TIMOB for further investigations. Please also attach your generated metabase frombuild/hyperloop/ios
, thx!Hey Brian, out of interest: When you include a Foundation class (e.g.
require('Foundation/NSURL')
), does that fix the issue? It might be related to a different issue of the same type. Thx!Hi Hans, I tried what you suggested but with no success, it still failling with the same error. I've just seen that you need the metabase, here is the gist (if you need a downloadable file let me know)[https://gist.github.com/Brianggalvez/1697f824da98bd1a6c002b848a79d49d]
I discovered a similar behavior when testing for TIMOB-24242. The
NSSet
will be populated withNSTouch
objects on the native side. Somehow Hyperloop fails to properly wrap those objects when retrieving them from theNSSet
, preventing any property access or method calls. I opened TIMOB-24383 to keep track of the root issue.Resolving as
Duplicate
to keep track in the root-ticket. Thx!Closing ticket as duplicate with reference to the linked issues.