[TIMOB-20250] Hyperloop: Cannot remove a HyperloopViewProxy from a TiViewProxy
| GitHub Issue | n/a |
|---|---|
| Type | Story |
| Priority | High |
| Status | Closed |
| Resolution | Fixed |
| Resolution Date | 2016-04-26T17:33:23.000+0000 |
| Affected Version/s | n/a |
| Fix Version/s | Release 5.4.0 |
| Components | Hyperloop, iOS |
| Labels | hyperloop, proxy |
| Reporter | Hans Knöchel |
| Assignee | Pedro Enrique |
| Created | 2016-01-19T22:27:35.000+0000 |
| Updated | 2017-03-16T22:50:34.000+0000 |
Description
We added support for adding a
HyperloopViewProxy to the Titanium view hierarchy, but not for removing them again. We should do a similar check like [here](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiViewProxy.m#L191) to get the TiViewProxy correctly.
The thrown error: Invalid type passed to function. expected: TiViewProxy, was: HyperloopClass -\[TiViewProxy remove:\] (TiViewProxy.m:266)
[~penrique] Thinking about this issue, would it make sense to check for the HyperloopViewProxy [here](https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiViewProxy.m#L286) and call
setNativeView:nilto reset the native view?PR: https://github.com/appcelerator/titanium_mobile/pull/7956
Demo:
var UIView = require("UIKit/UIView"), UIColor = require("UIKit/UIColor"), CGRectMake = require("CoreGraphics").CGRectMake, window = Ti.UI.createWindow({layout: "vertical"}); // HL View var view1 = UIView.alloc().initWithFrame(CGRectMake(20,20,100,100)); view1.setBackgroundColor(UIColor.redColor()); // TI View var view2 = Ti.UI.createView({ top: 20, left: 20, width: 100, height: 100, backgroundColor: "green" }); var btn1 = createButton("Remove HL View", function() { window.remove(view1); }); var btn2 = createButton("Remove TI View", function() { window.remove(view2); }); window.add(view1); window.add(view2); window.add(btn1); window.add(btn2); window.open(); // Button Helper function createButton(title, cb) { var btn = Ti.UI.createButton({ title : title, height: 40, width: 200, top: 20, backgroundColor: "#fff" }); btn.addEventListener("click", cb); return btn; }Closing ticket as fixed.