he conseguido un iphone

Re: he conseguido un iphone

Postby mastintin » Fri Nov 05, 2010 6: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.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby Daniel Garcia-Gil » Fri Nov 05, 2010 7:31 pm

pregunto (realmente no he googleado)

desde window se incluye el RES al exe... pero como se hace aqui?
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: he conseguido un iphone

Postby mastintin » Fri Nov 05, 2010 7: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
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby mastintin » Fri Nov 05, 2010 9: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: 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
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby mastintin » Fri Nov 05, 2010 10:24 pm

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 ;
}



 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby Antonio Linares » Fri Nov 05, 2010 11:38 pm

Manuel,

Genial! :-)

Enhorabuena!
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41461
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: he conseguido un iphone

Postby mastintin » Sat Nov 06, 2010 8:07 am

El codigo anterior solo me devuelve 1 objeto , cuando realmente tenemos puestos muchos mas controles ... ¿? .
topLevelObjs tiene solo el view .
Saludos.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby mastintin » Sat Nov 06, 2010 9: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
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby mastintin » 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: 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 )
   
}   

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby mastintin » Sat Nov 06, 2010 10:28 am

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 );    
   
}

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby mastintin » 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: 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

 
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby Antonio Linares » Sat Nov 06, 2010 12:38 pm

Manuel,

Muy bueno, muchas gracias! :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41461
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: he conseguido un iphone

Postby Daniel Garcia-Gil » Sat Nov 06, 2010 1: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!! :D
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: he conseguido un iphone

Postby mastintin » Sat Nov 06, 2010 6: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.
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

Re: he conseguido un iphone

Postby mastintin » Sun Nov 07, 2010 9:38 am

Setbagenumber funcionando :
Image

IMAGETOROUNDIMAGE funcionando .
Image

IMAGEREFLESFROMIMAGEVIEW funcionando:
Image
User avatar
mastintin
 
Posts: 1516
Joined: Thu May 27, 2010 2:06 pm

PreviousNext

Return to FiveMac / FivePhone (iPhone, iPad)

Who is online

Users browsing this forum: No registered users and 4 guests