Primera funcion operativa : recupera un view desde recursos . Todo subido al repositorio nibs.m , tutornibs.prg, y label.prg y view.prg
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
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 :
......
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