This is a continuation of the discussion from the API page. http://developer.anscamobile.com/reference/index/nativenewwebview [import]uid: 7559 topic_id: 24291 reply_id: 324291[/import]
Help,
I really do not know how to position this newWebView :
If i put top = 0, the webview is about at x = -40 and if i put top = 40, the webview is about x = 40 !!
How can I manage that ?
Frédéric
[import]uid: 5578 topic_id: 24291 reply_id: 99021[/import]
You need to supply some code showing what you are doing so we can help. [import]uid: 7559 topic_id: 24291 reply_id: 99276[/import]
There’s definitely something very wrong about newWebView and it’s placement of the view.
I was trying to get some 90 degree rotated ads going (argh), and had very little luck due to this problem. It appears to vary in behaviour between iPhone and iPad in the XCode simulator.
Even the simplest of cases, placing a newRect and a newWebView with the same coordinates, has them show up at different locations, with the webView pivoting about some point outside of it’s rectangle (it almost appears to be pivoting about the point where it *should* be located).
Simple case:
build.settings:
settings = {
orientation = {
default = “portrait”,
supported = { “portrait”, },
},
iphone = {
plist= { UIApplicationExitsOnSuspend=true, }
}
}
config.lua:
application = {
content = {
width = 768,
height = 1024,
scale = “letterbox”,
},
}
main.lua:
local x = 100
local y = 100
local w = 320
local h = 50
local r = display.newRect(x,y,w,h)
r:setFillColor(255, 0, 0)
local w = native.newWebView(x,y,w,h)
w:request(‘http://www.anscamobile.com’)
—[[ This shows it pivoting around a far off reference point
transition.to(r, { time=10000, rotation=90 })
transition.to(w, { time=10000, rotation=90 })
–]]
I thought I could get things working by always creating the webpopup at 0,0, but even that seems to show up in different spots between iPhone and iPad.
This feature seems pretty useless if you can’t control where things are placed.
This is with 2012.773.
Update: More info, in case anyone is listening or checking this out. With some quick testing, it seems that it may be related to dynamic image scaling. If I set x/y to 320/480 in config.lua, newWebView seems to behave as expected when the XCode simulator is set for iPhone mode (but messes up in iPad mode). Similarly, if I set x/y to 768/1024, newWebView works as expected for the iPad, but messes up when in iPhone mode.
-d [import]uid: 40450 topic_id: 24291 reply_id: 100687[/import]
I am working on an iOS project that will require native.newWebView
The Apple documentation refers to a setting for their webview object:
webView.mediaPlaybackRequiresUserAction=FALSE;
This setting will, for example, allow videos to automatically begin playing without the user having to tap the webView itself to start the video.
Question: Is there such a setting / command for Corona lua native.newWebView, or any other way to force the webView.mediaPlaybackRequiresUserAction = FALSE setting?
Thank you in advance for any info you can provide. [import]uid: 142947 topic_id: 24291 reply_id: 101638[/import]
Hello
I can not intercept click on html link with that code :
local function webListener(event)
if event.type == "link" then
local url = event.url
--storyboard.villeSelected = utils.checkForUrlEmptyness(url)
storyboard.gotoScene( "cities", "slideLeft", 500 )
--webview:stop()
end
end
local hauteurMax = display.viewableContentHeight - (35+48+45-4)
local largeurMax = 312
local top = 20
webView = native.newWebView(2, top, largeurMax, hauteurMax)
webView:request("gmap\_world.html", system.CachesDirectory )
webView:addEventListener("urlRequest", webListener)
Maybe the “link” test is not good ?
[import]uid: 5578 topic_id: 24291 reply_id: 102076[/import]
I am trying to use native.newWebView to open a video inside a webview window in an app. In iOS, UIWebView has a parameter:
mediaPlaybackRequiresUserAction = false
which allows a video to being playing automatically without the user having to tap the window to start the video.
Is there a way to have native.newWebView set a similar parameter to the one described above? [import]uid: 142947 topic_id: 24291 reply_id: 102088[/import]
Hi all!
I used this code, created the Android app, installed, but nothing show up on the screen…
local webview = native.newWebView( 10, 10, 700, 1000 )
webview:request( “http://www.anscamobile.com” )
Is there something so wrong in my code?
Thank you!
[import]uid: 86439 topic_id: 24291 reply_id: 105470[/import]
On iOS, if I am authenticated to Facebook from within the Safari app or via the Corona Facebook API should I also be authenticated when I open a Facebook URL from within a webView/webPopup? In other words, do we get to share context with the system browser? [import]uid: 117383 topic_id: 24291 reply_id: 105938[/import]
Please Help,
a) GOOD
I made a local html with select options and
when I set webview’s position for top of screen everyting is fine.
w = native.newWebView( 10, 10, 200, 20 )
w:request(“mySelect.html”, system.DocumentsDirectory)
b) NOT GOOD
But when I set webview’s position to middle of screen I cannot dropdown the menu and select doesn’t usable…
w = native.newWebView( 100, 100, 200, 20 )
w:request(“mySelect.html”, system.DocumentsDirectory)
Any Idea ?
Cheers,
Zsolt [import]uid: 126421 topic_id: 24291 reply_id: 109395[/import]
I’m also seeing some strange positioning. I have a 1280x800 app set to zoomEven.
When I do this I expect it to be in the middle of the screen, and take up the whole iPad viewable area…
local webView = native.newWebView( 128, 16, 1024, 768 )
Instead it shows up about 30 or so pixels off in both axis.
Any help? [import]uid: 91921 topic_id: 24291 reply_id: 109619[/import]
Fixed my own problem, it was due to the zoomEven scaling. Worked around it by changing to
local webView = native.newWebView( 106, 0, 1067, 800 )
Silly mistake. [import]uid: 91921 topic_id: 24291 reply_id: 109624[/import]
@voritka - newWebView is only supported on iOS currently per the docs.
[import]uid: 31041 topic_id: 24291 reply_id: 110030[/import]
Is there any way to bring other elements above the webview? It seems I cannot add a webview to a localgroup? [import]uid: 91921 topic_id: 24291 reply_id: 110064[/import]
@ dr_stripes no way : all native objects are above all others.
[import]uid: 5578 topic_id: 24291 reply_id: 111733[/import]
I have a question about the native.newWebView.
When I set the second argument like below, the object appears at the location where I don’t expect,at Y=364.
How can I avoid this situation?
An example is below.
– config.lua
[lua]application = {
content = {
width = 640,
height = 960,
scale = ‘letterbox’,
xAlign = ‘center’,
yAlign = ‘center’,
},
}[/lua]
– main.lua
[lua]display.setStatusBar(display.HiddenStatusBar)
local Width = display.contentWidth
local Height = display.contentHeight
local Y = 88
local spr, msg, web
spr = display.newRect(0, 0, Width, Y)
spr.strokeWidth = 2
spr:setFillColor(0, 0, 0)
spr:setStrokeColor(0xff, 0xff, 0xff)
msg = display.newText(’’, Width/2, Y*0.5, native.systemFont, 80)
msg:setTextColor(0xff, 0xff, 0xff)
web = native.newWebView(0, Y, Width, Height-Y)
web:request(‘http://www.coronalabs.com/’)
msg.text = tostring(web.y)[/lua] [import]uid: 102056 topic_id: 24291 reply_id: 115302[/import]
I am having trouble doing what I thought should be simple.
I would like my native.newWebView to adjust from portrait to landscape when a user rotates the device.
I am using an iPad.
If i try not trying to do anything in code to respond to an orientation change, the orientation is changed but if portrait used the whole screen of device. Then width and height are not adjusted for landscape (black area on right side of screen, cannot scroll to base of web page since content is cut off.
So I tried to adjust width and height like this
local \_W, \_H = display.contentWidth, display.contentHeight
local function oriChange(event)
if event.type == "portrait" or event.type == "portraitUpsideDown" then
webView.height = \_H
webView.width= \_W
else if event.type == "landscapeLeft" or event.type == "landscapeRight" then
webView.height = \_W
webView.width= \_H
end
end
end
..
Runtime:addEventListener("orientation", oriChange)
webView = native.newWebView(0, 0, \_W, \_H)
webView:request("http://www.goshen.edu")
group:insert(webView)
webView:setReferencePoint(display.TopLeftReferencePoint)
This results in a display that is more and more distorted with each orientation change.
It does work, if instead of trying to set width and height of an existing object, I create a new native.newWebView() object.
But then I have to request the web page again with each change in orientation, and my network is too slow to wait for the page to load over and over again.
So i changed oriChange to:
local function oriChange(event)
if event.type == "portrait" or event.type == "portraitUpsideDown" then
webView.rotation=0
else if event.type == "landscapeLeft" or event.type == "landscapeRight" then
webView.rotation=90
end
end
end
This works better. But I have a black rectangle at the left in landscape and a back rectangle at bottom in portrait view after each rotation of the device.
The back rectangles will be filled in with web content, if I: shake the device, lay the iPad face up on a table, or lay the iPad face down.
Why does shaking or laying the iPad down, fix the issue?
What can I do to avoid having to tell users to shake the iPad? (I would rather have them do that than call native.newWebView on an orientation change and wait for the page to be downloaded again-which is the only approach that I can get to work correctly)
confi.lua contains:
application =
{
content =
{
width = 768,
height = 1024,
scale = "letterbox",
fps = 30,
antialias = false,
xalign = "left",
yalign = "top"
}
}
Thanks for your assistance or insights. [import]uid: 158629 topic_id: 24291 reply_id: 116081[/import]
Is it possible to add a event listener for touch with webview? I need to read gestures and change page or scene depending on this. [import]uid: 106083 topic_id: 24291 reply_id: 116583[/import]
i have got a big problem.
i am using webview in my app.
however while i request a URL that is ‘APP STORE’
like
http://itunes.apple.com/tw/app/le-tou-dui-dui-jiang/id516551775?mt=8
webview will get nothing just left all blank.
not like native.openURL(url) that will escape current APP and jump to
app store for user to download
how could i make this possible in webview? [import]uid: 25057 topic_id: 24291 reply_id: 117672[/import]
Maybe you should send a link like :
[html]macappstore://itunes.apple.com/fr/app/borderlands-game-of-the-year/id411888529?mt=12ign-msr=http%3A%2F%2Fwww.google.fr%2Furl%3…rlands-game-of-the-year%252Fid411888529%253Fmt%253D12%26ei%3DFZ4XUISTJcWphAe2yoHwDQ%26usg%3DAFQjCNExZHsS7fxXbQikNsiyaERRI7npWA.[/html]
or something shorter like :
[html]macappstore://itunes.apple.com/fr/app/borderlands-game-of-the-year/id411888529[/html]
(did not try) [import]uid: 5578 topic_id: 24291 reply_id: 117673[/import]