2009-02-24 8 views

Respuesta

2

Sí tipo de posible. Simplemente cree una vista nueva usando un controlador de vista y cree una instancia de esa vista en su clase. Luego, en una operación, podrías eliminar y agregar subvistas. Eso es sólo un Tho rápida y fácil manera, se puede entrar en muchos más detalles de cómo se manejaría cada vista, etc.

Editar de Solicitud: En su clase, debe crear una instancia de la misma en el interfaz así:

MyClass *myClass; (make sure to alloc and init in the init or awakeFromNib method) 

luego hacer una instancia del delegado de la aplicación en el IBAction así:

MyAppDelegate *myAppDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; 

y entonces usted puede hacer esto para cambiar de una vista a otra:

[self removeFromSuperView]; (or self.view in case this is a view controller) 
[[myAppDelegate window] addSubview:myClass]; 
+0

gracias por ur respuesta. ¿Me puede dar algún ejemplo o código de muestra? – Nasir

1

Usted puede hacer algo como lo siguiente para agregar una vista mediante programación:

 //If you create controllers via XCode, just link them in the .h file with IBOutlet 
    UIViewController *aViewController = [[UIViewController alloc] initWithNibName:@"YourNibName" bundle:[NSBundle mainBundle]]; 
    self.viewController = aViewController; 
    [aViewController release]; 
    // Add the view controller's view as a subview of the window 
    UIView *controllersView = [viewController view]; 
    [window addSubview:controllersView]; 
    [window makeKeyAndVisible]; 
Cuestiones relacionadas