Difference between TiProxy and TiViewProxy in titanium

449 Views Asked by At

I'm now developing a module for titanium application. I have already created module using proxy. (TiProxy). The new module I'm creating is based on view. So I'm trying to use TiViewProxy.

But I'm confused with some terms:

  1. What is the major difference between TiProxy and TiViewProxy ?
  2. Is there any naming convention for TiViewProxy files ? If we are using TiProxy, then we add proxy after the file name. Is there anything like for view proxy ?

I referred iOS Module Development Guide but there is nothing about the naming convention.

Please help me. Thanks in advance

1

There are 1 best solutions below

0
On

TiViewProxy is special proxy that has "built in magic" for views. It participates, for example, in the UI layout cycle.

Assuming your module only has one view it wants to expose to Ti, you should call your view <ModuleName>View and your proxy <ModuleName>ViewProxy. This will have the benefit of participating in the built-in magic, and your ability to use myModule.createView() from within JS.

In the iOS module development it is mentioned that you should implement

-(void)frameSizeChanged:(CGRect)frame bounds:(CGRect)bounds

(probably by doing something like [TiUtils setView:myView positionRect:bounds];) -- that's how Ti lets you know your view has been positioned/resized. If you changed your view's position/size you should let Ti know:

[(TiViewProxy*)[self proxy] setHeight:NUMFLOAT(height)];

(if, for example, your view changed its height)