Page 20 of 43

Re: he conseguido un iphone

PostPosted: Fri Nov 05, 2010 6:52 pm
by mastintin
Antonio he mirado lo de llamar a una nib para cargar desde ella un view y tampoco consiguo cargarla .Según lo que he leido por internet parece que el truco esta en llamarla en applicationDidFinishLaunching .
Veo que esta definido este evento en mainapp y que pasa "algo" a harbour , pero no acabo de ver la manera de poder incluir una linea que llame a una nib determinada.¿ quizas pasandosela en un oninit ,aprovechando la llamada a harbour ?
Saludos.

Re: he conseguido un iphone

PostPosted: Fri Nov 05, 2010 7:31 pm
by Daniel Garcia-Gil
pregunto (realmente no he googleado)

desde window se incluye el RES al exe... pero como se hace aqui?

Re: he conseguido un iphone

PostPosted: Fri Nov 05, 2010 7:59 pm
by mastintin
Aquí creas archivos nib ,equivalentes a una dll
de recursos .
La llamas desde el ejecutable y listo.(tenemos que mirar como llamarlas)
Las nib se meten dentro del directorio
app como cualquier otro archivo.
Sino recuerdo mal una nib puede estar encriptada para que no se pueda abrir

Re: he conseguido un iphone

PostPosted: Fri Nov 05, 2010 9:50 pm
by mastintin
He conseguido llamar un view colocado en un nib desde una funcion ....
la funcion cuelkga de una accion de un boton en el view principal ...
Code: Select all  Expand view


HB_FUNC( LLAMAVIEW )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );

    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"Hola" owner:window options:nil];
   
    if (topLevelObjs == nil)   
                MsgInfo(@"no encuentra nada");
   
    UIView * control = [ topLevelObjs objectAtIndex : 0 ];
   
    if (control == nil) 
        MsgInfo(@"no encuentra nada ")
   
        [window addSubview: control  ];
       
      }
 

Image

Re: he conseguido un iphone

PostPosted: Fri Nov 05, 2010 10:24 pm
by mastintin
Mejor aun :
Code: Select all  Expand view


HB_FUNC( LLAMAVIEW )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );

    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"Hola" owner:window options:nil];
   
  for ( NSObject * obj in topLevelObjs )
{
if ( [obj isKindOfClass:[UIView class]] )
{
return (UIView*)obj;
}
}
return nil ;
}

     
 


para el NavigationController

Code: Select all  Expand view

HB_FUNC( LLAMANavController )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );

    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"Hola" owner:window options:nil];
   
  for ( NSObject * obj in topLevelObjs )
{
if ( [obj isKindOfClass:[UINavigationController class]] )
{
return (UINavigationController*)obj;
}
}
return nil ;
}



 

Re: he conseguido un iphone

PostPosted: Fri Nov 05, 2010 11:38 pm
by Antonio Linares
Manuel,

Genial! :-)

Enhorabuena!

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 8:07 am
by mastintin
El codigo anterior solo me devuelve 1 objeto , cuando realmente tenemos puestos muchos mas controles ... ¿? .
topLevelObjs tiene solo el view .
Saludos.

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 9:10 am
by mastintin
Daniel Garcia-Gil wrote:pregunto (realmente no he googleado)

desde window se incluye el RES al exe... pero como se hace aqui?


Daniel mirate esto :
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/IB_UserGuide/BuildingaNibFile/BuildingaNibFile.html

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 10:02 am
by mastintin
Avance , Consigo asignar el texto al label mediante su tag y lo mismo al switch . Con el boton casca ( culpa mia probablemente no se hacerlo bien ) .
Saludos.

Code: Select all  Expand view

HB_FUNC( HOLA )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );

    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"Hola" owner:window options:nil];

        UIView * view = [ topLevelObjs objectAtIndex : 0 ];

    UILabel *nameLabel = (UILabel*) [view viewWithTag:3];
    nameLabel.text = @"Name";    

    Switch * miswitch = (Switch *) [view viewWithTag:66];
    [ miswitch setOn : NO animated : YES ]

     
    [window addSubview:  view ];
           
     hb_retnl( ( LONG ) view )
   
}   

 

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 10:28 am
by mastintin
En dos funciones : una coge el view , la otra asigna sus elementos :
Code: Select all  Expand view

 abtn[1]:bAction:={|| yo:=Adios(oWnd:hwnd) , tu:=Micontrol(yo,3), SETLABELFONT(tu,"Arial",50) ,SETLABELTEXT(tu,"LUYEGO")) }

  


Code: Select all  Expand view





HB_FUNC( ADIOS )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );
   
    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed:@"Hola" owner:window options:nil];
   
    UIView * view = [ topLevelObjs objectAtIndex : 0 ];
   
 //   UILabel *nameLabel = (UILabel*) [view viewWithTag:3];
 //   nameLabel.text = @"Name";      
   
//  Switch * miswitch = (Switch *) [view viewWithTag:66];
 //   [ miswitch setOn : NO animated : YES ];   
   
    [window addSubview:  view ];
   
    hb_retnl( ( LONG ) view );
   
}  


HB_FUNC( MICONTROL )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );
    ;
   
    NSObject * miobj = (NSObject *) [window viewWithTag:hb_parnl( 2 )];
       
    hb_retnl( ( LONG ) miobj );    
   
}

 

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 11:45 am
by mastintin
Primera funcion operativa : recupera un view desde recursos . Todo subido al repositorio nibs.m , tutornibs.prg, y label.prg y view.prg
Code: Select all  Expand view

HB_FUNC( GETVIEWRESOURCE )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );
    NSString * cNib  = hb_NSSTRING_par( 2 );
   
    NSArray *topLevelObjs = nil;
    topLevelObjs = [[NSBundle mainBundle] loadNibNamed: cNib owner:window options:nil];
   
    UIView * view = [ topLevelObjs objectAtIndex : 0 ];
   
    [window addSubview:  view ];
   
   hb_retnl( ( LONG ) view );
   
}  

HB_FUNC( GETCONTROLRESOURCE )
{
    UIWindow * window = ( UIWindow * ) hb_parnl( 1 );
   
    NSObject * miobj = (NSObject *) [window viewWithTag:hb_parnl( 2 )];
           
    hb_retnl( ( LONG ) miobj );    
   
}



 


y metodos para tView y tLabel
Code: Select all  Expand view

METHOD Resources( oWnd, cResource ) CLASS TView
   ::hWnd = GETVIEWRESOURCE( oWnd:hWnd,cResource )
      AAdd( GetAllWin(), Self )   
return Self

METHOD Resources( oWnd, idResource ) CLASS TLabel
   ::hWnd = GetControlResource( oWnd:hWnd,idResource )        
return Self

 


Ejemplo funcionando partiendo de tutorbutton :

Code: Select all  Expand view

  ......
  abtn[1]:bAction:={|| llamaview(ownd) }
.....
   
return nil

Function llamaview(ownd)

local oView:=tView():resources(ownd,"Hola")
local oLabel:=tLabel():resources(oView,3)
 oLabel:SETFONT("Helvetica",20)
 olabel:setText("SI")

Return nil

 

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 12:38 pm
by Antonio Linares
Manuel,

Muy bueno, muchas gracias! :-)

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 1:25 pm
by Daniel Garcia-Gil
mastintin wrote:
Daniel Garcia-Gil wrote:pregunto (realmente no he googleado)

desde window se incluye el RES al exe... pero como se hace aqui?


Daniel mirate esto :
http://developer.apple.com/library/mac/#documentation/DeveloperTools/Conceptual/IB_UserGuide/BuildingaNibFile/BuildingaNibFile.html


Manuel

GRACIAS!! :D

Re: he conseguido un iphone

PostPosted: Sat Nov 06, 2010 6:20 pm
by mastintin
He subido un monton de pequeñas nuevas funciones que estan aun sin probar al repositorio .
Queda pendiente la implementacion del evento llamado por el evento del NStimer , y probar y limpiar el código .
Yo por hoy lo dejo ....
Un saludo.

Re: he conseguido un iphone

PostPosted: Sun Nov 07, 2010 9:38 am
by mastintin
Setbagenumber funcionando :
Image

IMAGETOROUNDIMAGE funcionando .
Image

IMAGEREFLESFROMIMAGEVIEW funcionando:
Image