2012-09-19 22 views
20

में गेम सेंटर लॉगिन लॉक लैंडस्केप में गेम सेंटर लॉगिन लॉक जब गेम सेंटर लोड हो जाता है तो इसका डिफ़ॉल्ट अभिविन्यास चित्र होता है। इसे लैंडस्केप मोड में लॉक करने के लिए, एक श्रेणी जोड़ा गया।केवल ओएस 6

@implementation GKMatchmakerViewController (LandscapeOnly) 

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{ 
    return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight); 
} 

-(NSUInteger)supportedInterfaceOrientations 
{ 
    return UIInterfaceOrientationMaskLandscape; 
} 

- (BOOL)shouldAutorotate { 
    return NO; 
} 
@end 

यह में IOS 6 .लेकिन iOS6 में नीचे यह एक त्रुटि से पता चलता ठीक काम कर रहा है।

न आया हुआ अपवाद 'UIApplicationInvalidInterfaceOrientation', कारण की वजह से एप्लिकेशन समाप्त: 'समर्थित झुकाव आवेदन के साथ कोई आम उन्मुखीकरण है, और shouldAutorotate लौटा रहा है हाँ'

कृपया एक समाधान समझा।

उत्तर

39

आखिर में मैंने ऐप्पल के आईओएस 6 release notes में उल्लिखित कार्यवाही का पालन करके दुर्घटना से परहेज किया।

वर्कअराउंड:

1.Apps should provide the delegate methodapplication:supportedIntefaceOrientationsForWindow and ensure that portrait is one of the returned mask values.

- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window 
{ 

    return UIInterfaceOrientationMaskAllButUpsideDown; 
} 

2. जब एक UIBNavigationController (या एक UIViewController) शामिल है, UINavigationController/UIViewController और अधिभावी supportedInterfaceOrientations उपवर्ग।

- (NSUInteger)supportedInterfaceOrientations 
    { 
     return UIInterfaceOrientationMaskLandscape; 
    } 

और

In buid summary supported orientations selected landscape right and landscape left.

अब खेल केंद्र दुर्घटना के बिना ठीक से काम कर रहा है।

+0

बहुत बढ़िया! आपने मेरा गधा बचाया :) – yonix

+0

धन्यवाद! मेरा गधा भी बचाया गया था :) –

+1

मेरे लिए भी काम किया, लेकिन मेरे मामले में मैं UIBNavigationController का उपयोग नहीं कर रहा था, लेकिन एक UIViewController (इसके सबक्लास), फिर भी मुझे अभी भी विधि संख्या 2 जोड़ना पड़ा। आप इस उत्तर में UIViewController के साथ UIBNavigationController को प्रतिस्थापित करना चाहेंगे। –

0

को 1 छोटी चीज़ जोड़नी है। उस बेवकूफ मुद्दे के साथ 2 दिनों के साथ संघर्ष। यदि उपरोक्त मदद नहीं करता है और आप UINavigationController invovled है (और आप पहले से ही यह उपवर्ग किया था) आप की जरूरत (AppDelegate में) के बाद:

[window setRootViewController:navigationController]; // use this 
// instead of [self.window addSubview:navigationController.view]; 

thanx 2 http://grembe.wordpress.com/2012/09/19/here-is-what-i/