Fondo & Objetivo: Tengo una aplicación para iPad basada en UISplitViewController, hasta ahora admitía 4 orientaciones, pero ahora quiero bloquearla solo en horizontal. Cambié shouldAutorotateToInterfaceOrientation
del controlador de vista izquierda para admitir solo el modo de paisaje, pero esto impide que se llame a viewWillAppear
.ViewWillAppear no se llama con UISplitViewController
Detalles: Mis controladores de vista de protectores y se organizan de la siguiente manera:
window
`-- splitVC (UISplitViewController)
`-- rootNav (UINavigationController)
`-- hvc (HostManagerViewController, derived from UIViewController)
`-- detailViewController (DetailViewController, derived from UIViewController)
Esto se implementa en la App Delegado de la siguiente manera:
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
HostManagerViewController *hvc = [[[HostManagerViewController alloc]
initWithNibName:nil bundle:nil] autorelease];
self.detailViewController = [[[DetailViewController alloc]
initWithNibName:nil bundle:nil] autorelease];
UINavigationController *rootNav = [[[UINavigationController alloc]
initWithRootViewController:hvc] autorelease];
UISplitViewController *splitVC= [[[UISplitViewController alloc] init] autorelease];
[splitVC setViewControllers:[NSArray arrayWithObjects:rootNav,
detailViewController, nil]];
splitVC.delegate = detailViewController;
[window addSubview:splitVC.view];
[window setRootViewController:splitVC];
return YES;
}
viewWillAppear
se llama cuando tanto DetailViewController.m
y HostManagerViewController.m
contienen
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
Console output:
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Hostmanager: Viewdidload
Should rotate called to hostmanager with 1
Hostmanager: viewwillappear
Pero cuando cambio 'código de s a
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientationIsLandscape(interfaceOrientation));
}
luego' HostManagerViewController
viewWillAppear` de HostManagerViewController no se invoca. salida de la consola
Should rotate called to hostmanager with 1 (1 is the numeric value of interfaceOrientation)
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 1
Should rotate called to hostmanager with 3
Hostmanager: Viewdidload
Should rotate called to hostmanager with 1
Sólo los modos horizontal están soportados en el Info.plist
EDIT: mensajes insertados NSLog para realizar un seguimiento shouldAutorotateToInterfaceOrientation
, viewWillAppear
y ViewDidLoad
¿es posible que cargue una muestra de este proyecto? – ACBurk
¿con qué versión de iOS está ejecutando esto? – ACBurk
Estoy usando 4.3. Se puede reducir a un testcase más pequeño. ¿Dónde lo cargo entonces? –