1

Gezinme denetleyicisine yerleştirilmiş iki görüntü denetleyicim var, İlk görüntü denetleyicim dönüyor, oysa ikinci görüntü denetleyicim her zaman dikey modda açılmalı İlk görünüm denetleyicideki manzara modundayım Sadece ikinci resmimi açmak istiyorum sadeceGörünüm denetleyicimi her zaman dikey modda açmaya zorlama

İkinci görüntüleme denetleyicisini ilk önce segue iterek sunarım.

+0

olası çift [dikey modda kalmak görünüm denetleyicisi zorlama?] (http://stackoverflow.com/questions/16720968/how-to portrede sunmak solgun sınıfında, bu yöntem yerleştirin -görüntü-denetleyici-için-içinde-modunda-modu) –

+0

Olası yinelenen [Nasıl bir UIViewController iOS 6'da Portait yönlendirmeye zorlamak için] (http://stackoverflow.com/questions/12520030/how-to force-a-UIViewController-için-Portait yönlendirme-içinde-iOS-6) – kb920

cevap

2

Sen ikinci VC (portre) sunmak hemen önce çağrı ikinci VC

üzerinde shouldAutorotate uygulamak zorunda kalacak

if([UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeLeft || [UIDevice currentDevice].orientation == UIDeviceOrientationLandscapeRight) { 
     [[UIDevice currentDevice] setValue:[NSNumber numberWithInteger: UIInterfaceOrientationPortrait] forKey:@"orientation"]; 
} 
0

Çözüm 1: Bir özel UINavigationController alt sınıfını oluşturup bunun gibi bu yöntemleri geçersiz kılmak :

@interface LockedNavigationViewController() 

@end 

@implementation LockedNavigationViewController 

-(BOOL)shouldAutorotate { 
    return UIInterfaceOrientationMaskPortrait; 
} 

#if __IPHONE_OS_VERSION_MAX_ALLOWED < 90000 
- (NSUInteger)supportedInterfaceOrientations 
#else 
- (UIInterfaceOrientationMask)supportedInterfaceOrientations 
#endif 
{ 
    return UIInterfaceOrientationMaskPortrait; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return UIInterfaceOrientationPortrait; 
} 

@end 
0

enter image description here

Projenizi seçin -> genel, ardından yukarıdaki görüntüyü izleyin.

1

Sen için ur AppDelegate Class bu yöntemi kullanmak ve bool var

-(NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window { 
    if(self.isDisplayInPoratrait){ 
     return UIInterfaceOrientationMaskPortrait; 
    else 
     // return ur required orientation 
} 

self.isDisplayInPoratrait ile koruyabilirsiniz AppDelagate sette u portresini de sunmak istiyorum sınıfta bu değişken evet beyan bool değişkendir. U

-(BOOL)shouldAutorotate { 
    return NO; 
} 

-(UIInterfaceOrientationMask)supportedInterfaceOrientations { 
    return UIInterfaceOrientationMaskPortrait; 
} 

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation { 
    return UIInterfaceOrientationLandscapeLeft; 
} 
İlgili konular