j'ai un photoBroser
qui est héritée uiview
:iOS: Comment laisser un `portrait de soutien uiview` et l'orientation paysage
@interface SDPhotoBrowser : UIView <UIScrollViewDelegate>
Mais maintenant j'ai une obligation de laisser le photoBroser
soutien iphone
portrait et paysage orientation, et comment le faire?
EDIT: Dans ma demande, mon application ne supporte que l'orientation portrait
, que dans mon photoBrowser
qui est uiview
, je veux soutenir l'orientation portrait and landscape
.
EDIT: Je demande la réponse de J.Hunter
, et sa réponse est très bonne, dans le codage en fait, je suggère une fonction pour changer portrait and landscape orientation
.Lorsque je rejette mon photoBrowser
, il arrive un problème, après mon photoBrowser
destituer, la appareil est landscape orientation
encore, et donc j'utilise le code ci-dessous pour laisser mon appareil portrait orientation
, puis mon photoBrowser
rejeter, donc montrer raisonnablement.
//(force landscape:[self interfaceOrientation:UIInterfaceOrientationLandscapeRight];)
//(force Portrait:[self interfaceOrientation:UIInterfaceOrientationPortrait];)
+ (void)interfaceOrientation:(UIInterfaceOrientation)orientation
{
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
int val = orientation;
// from 2
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
}
Cette fonction peut être utile pour un code support portrait and landscape orientation
parfait.
Est-ce votre soutien d'applications à la fois portrait et orientation paysage? Ou seulement soutenir l'orientation portrait? –
Dans Xcode à la racine du projet, vous avez Général> Infos sur le déploiement> Orientation du périphérique ....., puis vérifiez l'orientation souhaitée. –
@ J.Hunter Je m'excuse pour ma question partielle, et j'ai complété quelques description à ma question. – lme