Using Corona as a native wrapper for Web-based business apps

I’d like to know if anyone has done this and how they handled rotation of the webview?

The simplest method is to change the rotation property. With Graphics 2.0 you could add a fancy effect as a transition. I haven´t done this by myself yet but I will include something like this in the near future

I’ve been testing with the code below, but the on-device result is that the web view simply distorts. The problem with the rotation is that the width and height of the device are different, so I was hoping to change the width and height of the web view. If I don’t rotate the web view I have to account for device rotation in HTML/JS.

-- web app test display.setDefault( "background", 1, 0, 0 ) local pWidth, pHeight = display.actualContentWidth, display.actualContentHeight local webView = native.newWebView( pWidth/2, pHeight/2, pWidth-100, pHeight-100 ) webView:request( "http://www.coronalabs.com/" ) local orientations = {} orientations.portrait = { rotation=0, width=pWidth, height=pHeight, x=pWidth/2, y=pHeight/2 } orientations.portraitUpsideDown = { rotation=180, width=pWidth, height=pHeight, x=pWidth/2, y=pHeight/2 } orientations.landscapeLeft = { rotation=-90, width=pHeight, height=pWidth, x=pHeight/2, y=pWidth/2 } orientations.landscapeRight = { rotation=90, width=pHeight, height=pWidth, x=pHeight/2, y=pWidth/2 } local function onOrientationChange( event ) local currentOrientation = event.type print( "Current orientation: " .. currentOrientation ) local o = orientations[currentOrientation] transition.to( webView, { x=o.x, y=o.y, rotation=o.rotation, width=o.width, height=o.height, time=0 } ) print(o.x, o.y, o.rotation, o.width, o.height) end Runtime:addEventListener( "orientation", onOrientationChange )

The simplest method is to change the rotation property. With Graphics 2.0 you could add a fancy effect as a transition. I haven´t done this by myself yet but I will include something like this in the near future

I’ve been testing with the code below, but the on-device result is that the web view simply distorts. The problem with the rotation is that the width and height of the device are different, so I was hoping to change the width and height of the web view. If I don’t rotate the web view I have to account for device rotation in HTML/JS.

-- web app test display.setDefault( "background", 1, 0, 0 ) local pWidth, pHeight = display.actualContentWidth, display.actualContentHeight local webView = native.newWebView( pWidth/2, pHeight/2, pWidth-100, pHeight-100 ) webView:request( "http://www.coronalabs.com/" ) local orientations = {} orientations.portrait = { rotation=0, width=pWidth, height=pHeight, x=pWidth/2, y=pHeight/2 } orientations.portraitUpsideDown = { rotation=180, width=pWidth, height=pHeight, x=pWidth/2, y=pHeight/2 } orientations.landscapeLeft = { rotation=-90, width=pHeight, height=pWidth, x=pHeight/2, y=pWidth/2 } orientations.landscapeRight = { rotation=90, width=pHeight, height=pWidth, x=pHeight/2, y=pWidth/2 } local function onOrientationChange( event ) local currentOrientation = event.type print( "Current orientation: " .. currentOrientation ) local o = orientations[currentOrientation] transition.to( webView, { x=o.x, y=o.y, rotation=o.rotation, width=o.width, height=o.height, time=0 } ) print(o.x, o.y, o.rotation, o.width, o.height) end Runtime:addEventListener( "orientation", onOrientationChange )