FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveMac / FivePhone (iPhone, iPad) he conseguido un iphone
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Fri Nov 05, 2010 06:52 PM

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.

Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: he conseguido un iphone

Posted: Fri Nov 05, 2010 07:31 PM

pregunto (realmente no he googleado)

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

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Fri Nov 05, 2010 07:59 PM

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

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Fri Nov 05, 2010 09:50 PM
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 (fw): Select all Collapse
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  ];
        
      }

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Fri Nov 05, 2010 10:24 PM
Mejor aun :
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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 ;
}
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: he conseguido un iphone

Posted: Fri Nov 05, 2010 11:38 PM

Manuel,

Genial! :-)

Enhorabuena!

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 08:07 AM

El codigo anterior solo me devuelve 1 objeto , cuando realmente tenemos puestos muchos mas controles ... ¿? .
topLevelObjs tiene solo el view .
Saludos.

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 09:10 AM
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
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 10:02 AM
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 (fw): Select all Collapse
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 ); 
    
}
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 10:28 AM
En dos funciones : una coge el view , la otra asigna sus elementos :
Code (fw): Select all Collapse
 abtn[1]:bAction:={|| yo:=Adios(oWnd:hwnd) , tu:=Micontrol(yo,3), SETLABELFONT(tu,"Arial",50) ,SETLABELTEXT(tu,"LUYEGO")) }


Code (fw): Select all Collapse
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 );     
    
}
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 11:45 AM
Primera funcion operativa : recupera un view desde recursos . Todo subido al repositorio nibs.m , tutornibs.prg, y label.prg y view.prg
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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 (fw): Select all Collapse
  ......
  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
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 12:38 PM

Manuel,

Muy bueno, muchas gracias! :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 01:25 PM
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!! :-)
Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Sat Nov 06, 2010 06:20 PM

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.

Posts: 1516
Joined: Thu May 27, 2010 02:06 PM

Re: he conseguido un iphone

Posted: Sun Nov 07, 2010 09:38 AM
Setbagenumber funcionando :


IMAGETOROUNDIMAGE funcionando .


IMAGEREFLESFROMIMAGEVIEW funcionando: