Skip to content

Instantly share code, notes, and snippets.

@daniel-rueda
Created July 20, 2015 23:57
Show Gist options
  • Save daniel-rueda/75fdf03443ac4a64cf0a to your computer and use it in GitHub Desktop.
Save daniel-rueda/75fdf03443ac4a64cf0a to your computer and use it in GitHub Desktop.
// Crear un navigation controller usando un XIB
// Primero se debe crear el view controller inicial (root view controller)
// MyViewController cuenta con un archivo xib
MyViewController *viewController = [[MyViewController alloc] init];
// Se crear el navigationController para presentar el viewController
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
// Presentar el navigation controller (que ya incluye el view controller)
[self presentViewController:navigationController animated:YES completion:NULL];
// Ahora ya es posible usar self.navigationController desde MyViewController (En el método viewDidLoad, por ejemplo)
// En MyViewController.m (ejemplo)
- (void)showButtonPresed:(id)button
{
OtroViewController *otroController = [[OtroViewController alloc] init];
[self.navigationController pushViewController:otroController animated:YES]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment