Rotate with UITabBarController
Rotate with UITabBarController
ago 23Recentemente mi sono imbattuto in un problema abbastanza spinoso: non riuscivo a far ruotare una View contenente un Tab Bar Controller.
Le linee guida Apple suggeriscono che ogni subView debba restituire
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
UIInterfaceOrientationPortrait);
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES);
}
@end
UIInterfaceOrientationPortrait);
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES);
}
@end
purtroppo seguendo le linee guida della apple non ci sono riuscito, c’era qualche sottoclasse che non restituiva YES
alla fine, per ovviare al problema, ho dovuto seguire una pratica “sconsigliata” dalla Apple, cioè realizzare un Tab Bar Controller e richiamarne la classe dal Nib, cosi
// MyTabBarController.h
//
#import
@interface MyTabBarController : UITabBarController {
}
@end
// MyTabBarController.m
#import “MyTabBarController.h”
@implementation MyTabBarController
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
UIInterfaceOrientationPortrait);
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES);
}
@end
//
#import
@interface MyTabBarController : UITabBarController {
}
@end
// MyTabBarController.m
#import “MyTabBarController.h”
@implementation MyTabBarController
- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation {
UIInterfaceOrientationPortrait);
return (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES);
}
@end
Nota bene: interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown ? NO : YES)
serve per impedire che l’orientamento possa andare “sottosopra”(cosa che è sconsigliata dalle linee guida apple)..
Infine, per effettuare il collegamento, basta entrare sotto le proprietà del Nib e cambiarne la classe(da UITabBarController a MyTabBarController)
Sperando che alla Apple non si arrabbino

Hey there, I was viewing this blog from my iPhone and this seems to be somewhat odd. Believed you’d wish to be aware of. It’s actually a excellent blog post though, just didn’t mess that up.
Hi Mr. Merle
i just looked by my Ipod, and it is looking good. However, the code snippets do not work, but i think that if you want to see the code, you have the need to test it, and you must obtain a laptob or better to do this.
Thanks however for interesting about my blog
Bye
Fabio
Davvero un ottimo articolo, mi avete illuminato