Hey gang… I’ve seen the other post about the native webView, but only one guy seemed to be dealing with this, and it was not really pertinent to that thread, so I am starting a fresh one here specifically to orientation.
I’m trying to find the best way to handle all full screen orientation change of the native.newWebView without redrawing and resubmitting the request.
Below is my function that is handling the orientation change, which works properly, but I can’t seem to get the webview to resize properly. It just wants to shrink and resize improperly each subsequent orientation change.
Any ideas on how to accomplish this? I want to have a full screen webview that is able to change orientation and keep my url request session live.
[lua]local function onOrientationChange(event)
direction = event.type
delta = event.delta
–RESET GLOBAL WIDTH/HEIGHT
_W = display.contentWidth
_H = display.contentHeight
–ROTATE WEBVIEW
if direction == “portrait” then
–ROTATE TEXT ENTRY FIELD
if serverFieldPresent then
defaultField.x = _W * .5
–ROTATE INSTRUCTIONS
instruction.x = _W * .5
end
–SET bkg
bkg:setReferencePoint( display.CenterReferencePoint )
bkg.x = _W * .5
bkg.y = _H * .5
bkg.width = _W
bkg.height = _H
if webViewPresent then
print("Screen Height is " … _H)
–print("Webview is " … direction … " :: Delta is: " … delta)
webView.rotation = 0
webView.width = _W
webView.height = _H
end
elseif direction == “portraitUpsideDown” then
–ROTATE TEXT ENTRY FIELD
if serverFieldPresent then
defaultField.x = _W * .5
–ROTATE INSTRUCTIONS
instruction.x = _W * .5
end
–SET bkg
bkg:setReferencePoint( display.CenterReferencePoint )
bkg.x = _W * .5
bkg.y = _H * .5
bkg.width = _W
bkg.height = _H
if webViewPresent then
print("Screen Height is " … _H)
–print("Webview is " … direction … " :: Delta is: " … delta)
webView.rotation = 0
webView.width = _W
webView.height = _H
end
elseif direction == “landscapeLeft” then
–ROTATE TEXT ENTRY FIELD
if serverFieldPresent then
defaultField.x = _H * .5
–ROTATE INSTRUCTIONS
instruction.x = _H * .5
end
–SET bkg
bkg:setReferencePoint( display.CenterReferencePoint )
bkg.x = _H * .5
bkg.y = _W * .5
bkg.width = _H
bkg.height = _W
if webViewPresent then
print("Screen Height is " … _H)
–print("Webview is " … direction … " :: Delta is: " … delta)
webView.rotation = 0
print("Screen Height is " … _H)
webView.width = _W
webView.height = _H
end
elseif direction == “landscapeRight” then
–ROTATE TEXT ENTRY FIELD
if serverFieldPresent then
defaultField.x = _H * .5
–ROTATE INSTRUCTIONS
instruction.x = _H * .5
end
–SET bkg
bkg:setReferencePoint( display.CenterReferencePoint )
bkg.x = _H * .5
bkg.y = _W * .5
bkg.width = _H
bkg.height = _W
if webViewPresent then
print("Screen Height is " … _H)
–print("Webview is " … direction … " :: Delta is: " … delta)
print("Screen Height is " … _H)
–print("Webview is " … direction … " :: Delta is: " … delta)
webView.rotation = 0
print("Screen Height is " … _H)
webView.width = _W
webView.height = _H
end
end
end[/lua] [import]uid: 10361 topic_id: 30706 reply_id: 330706[/import]