मैं एक ही मुद्दा Cocos2d 2.0
को उपयोग करने का मेरे समस्या यह थी कि परियोजना कई वर्षों में विकसित किया गया था और RootViewController और UIViewController और MyRootViewController जैसे कुछ अब बाक़ी फ़ाइलें साथ किए थे, आदि
उन्होंने उस समय काम किया लेकिन स्पष्ट रूप से आज की समीक्षा समिति के साथ एक झंडा उठाया क्योंकि मुझे "सभी आईफोन ऐप्स को आईपैड पर काम करना चाहिए" अस्वीकृति नोटिस प्राप्त हुआ। जोर से चिल्लाने और अंततः हार को स्वीकार करने के बाद, मैंने सोचा कि नीति केवल ऐप आईफोन बनाने में काफी मुश्किल बनाती है। अगर मैं इसके बारे में गलत हूं तो मुझे बताएं।
भले ही मैं इसके बारे में परेशान था (और अभी भी), मैंने सोचा कि शायद मैं कम से कम एक जटिल समाधान के साथ परियोजना को साफ कर सकता हूं जो मूल समस्या को नियंत्रित करता है: डिवाइस रोटेशन + सामग्री रोटेशन। मैं एक और हालिया परियोजना से कुछ का उपयोग कर समाप्त हुआ जो काम कर रहा था और अधिक सुरुचिपूर्ण लग रहा था और वास्तव में काम करता था: बस मेरे ऐपडिलेगेट के शीर्ष पर MyNavigationController जोड़ें।
मैंने नीचे दिया गया कोड जोड़ा है। मुझे यकीन है कि इसे बेहतर किया जा सकता है। अगर आप इसे बढ़ा सकते हैं तो कृपया टिप्पणी करें।
नतीजतन, मैं पुरानी रूटव्यू कंट्रोलर और MyRootViewController फ़ाइलों को हटाने में सक्षम था, इसलिए अब इसे बनाए रखना आसान है। मैंने कभी भी उनके उद्देश्य को बहुत अच्छी तरह से नहीं समझा। अच्छा छुटकारा! AppDelegate.h में
मैं घोषित करने के लिए मैं क्या कर रहा था:
यहाँ प्रदर्शित करने और डिवाइस अभिविन्यास + सामग्री उन्मुखीकरण मिलान करने के लिए अपने समाधान है
// फ़ाइल
के शीर्ष @ इंटरफ़ेस MyNavigationController: UINavigationController @end
// AppDelegate.h इंटरफ़ेस अंदर
MyNavigationController * navController_;
// से पहले @end
@property (रीड-ओनली) MyNavigationController * navController फ़ाइल के नीचे;
यहां कोड है जो मेरे ऐपडिलेगेट के शीर्ष पर काम करता है।
- मैं विभिन्न दृश्यों को प्रदर्शित करने के लिए दोनों लैंडस्केप और पोर्ट्रेट मोड की जरूरत: मीटर
@implementation MyNavigationController
// The available orientations should be defined in the Info.plist file.
// And in iOS 6+ only, you can override it in the Root View controller in the "supportedInterfaceOrientations" method.
// Only valid for iOS 6+. NOT VALID for iOS 4/5.
-(NSUInteger)supportedInterfaceOrientations {
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
if (orientation == UIDeviceOrientationPortrait) {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// [director_ pushScene: [IPAD scene]];
} else {
[[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];
return UIInterfaceOrientationMaskPortrait;
}
} else if (orientation == UIDeviceOrientationLandscapeLeft) {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// [director_ pushScene: [IPAD scene]];
} else {
[[CCDirectorIOS sharedDirector] pushScene:[MainMenuScene scene]];
}
} else if (orientation == UIDeviceOrientationLandscapeRight) {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
// [director_ pushScene: [IPAD scene]];
} else {
[[CCDirectorIOS sharedDirector] pushScene:[MainMenuScene scene]];
}
} else if (orientation == UIDeviceOrientationPortraitUpsideDown) {
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
} else {
[[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
} else {
//do nothing
}
return UIInterfaceOrientationMaskLandscape;
}
//this is the one for iOS 6
- (BOOL)shouldAutorotate {
//NSLog(@"MyNavigationController - should Rotate ToInterfaceOrientation ...");
UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
// iPhone only
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
//NSLog(@"MyNavigationController - should Rotate iPhone");
if (orientation == UIDeviceOrientationPortrait) {
//NSLog(@"should Rotate iPhone orientation is Portrait");
[[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];
return UIInterfaceOrientationMaskPortrait;
}
if (orientation == UIDeviceOrientationPortraitUpsideDown) {
//NSLog(@"should Rotate iPhone orientation is PortraitUpsideDown");
[[CCDirectorIOS sharedDirector] pushScene:[VerticalDisplayLayer scene]];
return UIInterfaceOrientationMaskPortraitUpsideDown;
}
if (orientation == UIDeviceOrientationLandscapeLeft) {
//NSLog(@"should Rotate iPhone orientation is Landscape Left");
return UIInterfaceOrientationMaskLandscape;
}
if (orientation == UIDeviceOrientationLandscapeRight) {
//NSLog(@"should Rotate iPhone orientation is Landscape Right");
return UIInterfaceOrientationMaskLandscape;
}
return TRUE;
}
//return UIInterfaceOrientationIsLandscape(interfaceOrientation);
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
//NSLog(@"MyNavigationController - should Rotate iPad");
return TRUE;
}
return TRUE;
}
// Supported orientations. Customize it for your own needs
// Only valid on iOS 4/5. NOT VALID for iOS 6.
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)interfaceOrientation
{
// iPhone only
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone)
return TRUE;
//return UIInterfaceOrientationIsLandscape(interfaceOrientation);
if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
return TRUE;
// iPad only
// iPhone only
//return UIInterfaceOrientationIsLandscape(interfaceOrientation);
return TRUE;
}
// This is needed for iOS4 and iOS5 in order to ensure
// that the 1st scene has the correct dimensions
// This is not needed on iOS6 and could be added to the application:didFinish...
-(void) directorDidReshapeProjection:(CCDirector*)director
{
if(director.runningScene == nil) {
// Add the first scene to the stack. The director will draw it immediately into the framebuffer. (Animation is started automatically when the view is displayed.)
// and add the scene to the stack. The director will run it when it automatically when the view is displayed.
[director runWithScene: [MainMenuScene scene]];
}
}
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
// Assuming that the main window has the size of the screen
// BUG: This won't work if the EAGLView is not fullscreen
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGRect rect = CGRectZero;
//NSLog(@"MyNavigationController - Will RotateToInterfaceOrientation ...");
if(toInterfaceOrientation == UIInterfaceOrientationPortrait || toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
rect = screenRect;
} else if(toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
rect.size = CGSizeMake(screenRect.size.height, screenRect.size.width);
}
CCDirector *director = [CCDirector sharedDirector];
CCGLView *glView = (CCGLView *)[director view];
glView.frame = rect;
}
@end
यहाँ कारण है कि मैं इस का समाधान करना था है।
यहाँ कुछ स्क्रीनशॉट उस स्थिति
स्रोत
2015-07-09 00:47:35
आप आईपैड सिम्युलेटर पर इसे चलाने की कोशिश की है का वर्णन कर रहे हैं? क्या आपके पास @ 2x छवियां हैं? – Jamie