Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-20250] Hyperloop: Cannot remove a HyperloopViewProxy from a TiViewProxy

GitHub Issuen/a
TypeStory
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2016-04-26T17:33:23.000+0000
Affected Version/sn/a
Fix Version/sRelease 5.4.0
ComponentsHyperloop, iOS
Labelshyperloop, proxy
ReporterHans Knöchel
AssigneePedro Enrique
Created2016-01-19T22:27:35.000+0000
Updated2017-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)

Comments

  1. Hans Knöchel 2016-03-20

    [~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:nil to reset the native view?
  2. Hans Knöchel 2016-04-21

    PR: https://github.com/appcelerator/titanium_mobile/pull/7956
  3. Hans Knöchel 2016-04-21

    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;    
       }
       
  4. Lee Morris 2017-03-16

    Closing ticket as fixed.

JSON Source