How To make both portrait and landscape fit the screen (ios) c++

I want to change my screen according to device rotation(to supoort both portrait and landscape mode).I have change the code as
In RootViewController.mm

  • (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
    }
  • (NSUInteger) supportedInterfaceOrientations{
    #ifdef __IPHONE_6_0
    return UIInterfaceOrientationMaskAll;
    #endif
    }

and in AppController.mm

-(void) orientationDidChanged:(NSNotification*)notification
{
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIDeviceOrientationPortrait || orientation == UIDeviceOrientationPortraitUpsideDown)
{
cocos2d::CCSize s = cocos2d::Director::getInstance()->getOpenGLView()->getFrameSize();
if (s.width < s.height)
{
cocos2d::Director::getInstance()->getOpenGLView()->setFrameSize(s.width, s.height);
}
else
cocos2d::Director::getInstance()->getOpenGLView()->setFrameSize(s.height, s.width);

}
else if (orientation == UIDeviceOrientationLandscapeLeft || orientation == UIDeviceOrientationLandscapeRight)
{
    cocos2d::CCSize s =  cocos2d::Director::getInstance()->getOpenGLView()->getFrameSize();
    if (s.width > s.height)
    {
        cocos2d::Director::getInstance()->getOpenGLView()->setFrameSize(s.width, s.height);
    }
    else
        cocos2d::Director::getInstance()->getOpenGLView()->setFrameSize(s.height, s.width);
}
cocos2d::Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, ResolutionPolicy::NO_BORDER);

}

and in didFinishLaunchingWithOptions in AppController.mm i have add the code to add obserber as -

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationDidChanged:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

But when i rotate device from landscape to portrait my scene is not showing properly.How can i acheive taht?