Content Scaling

I have integrated Corona SDK project into existing xcode project using corona cards. 

On Corona SDK/Corona Simulator:

  • I am loading an image on the view port and it display as intended. Here’s the screenshot: link
  • Below is the configuration details:

config.lua

application = { content = { width = 720, height = 1280, scale = "letterbox", fps = 60, xAlign = "center", yAlign = "center" }, }

main.lua

local intro = display.newImageRect(params.base\_path .. "title.png", 1280, 720) intro.x = 640 intro.y = 360

The above works fine and the image fits correctly and maintains aspect ratio.

I have moved the code into “Corona” folder in the xcode project. When I run it in the iphone 7 simulator the image loads but does not load it correctly from position or scaling perspective. Here’s the screen shot: link

Here’s the Corona View Controller in xcode:

// Load corona view - (void)viewDidAppear:(BOOL)animated { \_coronaController = [[CoronaViewController alloc] init]; [self addChildViewController:\_coronaController]; CoronaView \*coronaView = (CoronaView \*)\_coronaController.view; coronaView.frame = self.view.frame; [self.view addSubview:coronaView]; // Transparent background coronaView.backgroundColor = [UIColor clearColor]; coronaView.opaque = NO; // Prepare params NSDictionary \*event = [NSDictionary dictionaryWithObjectsAndKeys: @"playEvent", @"name", @"playGame", @"phase", \_Name, @"gName", nil]; [coronaView run]; //Send event [coronaView sendEvent:event]; }

Any thoughts?

Resolved this issue by updating the following:
 

CGRect appFrame = [UIScreen mainScreen].bounds; \_coronaView.frame = CGRectMake(0, 0, appFrame.size.height, appFrame.size.width); [self.view addSubview:\_coronaView]; [\_coronaView setNeedsLayout];

Hope this helps others

Resolved this issue by updating the following:
 

CGRect appFrame = [UIScreen mainScreen].bounds; \_coronaView.frame = CGRectMake(0, 0, appFrame.size.height, appFrame.size.width); [self.view addSubview:\_coronaView]; [\_coronaView setNeedsLayout];

Hope this helps others