How do I get the browser to open a jpeg

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bmatichuk
Posts: 15
Joined: Tue Oct 12, 2010 7:19 am
Location: Edmonton

How do I get the browser to open a jpeg

Post by bmatichuk » Tue Jul 24, 2012 6:49 am

According to the documentation I should be able to do the following

-- We use this variable to store the id of the UIWebView native
-- control.
local sBrowserId

on preOpenCard
if the environment is not "mobile" then
exit preOpenCard
end if

-- Create our browser control and store the id
iphoneControlCreate "browser"
put the result into sBrowserId

-- Native controls start off invisible
iphoneControlSet sBrowserId, "visible", "true"
local theFile
put specialFolderPath("Documents") & "/test.jpg" into theFile

-- Set up a suitable initial url
iphoneControlSet sBrowserId, "url", "binfile:"&theFile

-- Make sure everything is the right size
resizeStack
end preOpenCard


However, when the browser loads, its empty.
Despite that fact that I've just saved this image.

local theFile
put specialFolderPath("Documents") & "/test.jpg" into theFile
export image "Bigimage" to file theFile as JPEG
put URL ("binfile:" & theFile) into image "Bigimage"

Which works fine. i.e. it saves an image then puts the same image back to verify that the save worked.

So what am I missing? Why won't the browser display the file?

-B

bmatichuk
Posts: 15
Joined: Tue Oct 12, 2010 7:19 am
Location: Edmonton

Re: How do I get the browser to open a jpeg

Post by bmatichuk » Tue Jul 24, 2012 7:31 am

Well I found the problem. Thanks to Gerry.
Here is his working code


on preOpenCard
local localURL
global mScrollerId
iphoneControlCreate "browser"
put the result into mScrollerId
iphoneControlSet mScrollerId, "visible", "true"
iphoneControlSet mScrollerId, "canBounce", "true"
iphoneControlSet mScrollerId, "autoFit", true
iphoneControlSet mScrollerId, "rect", (the left of this card , the top of this card, the right of this card , the bottom of this card )
put "file://" & specialFolderPath("Documents")&"/test.jpg" into localURL
replace " " with "%20" in localURL
iphoneControlSet mScrollerId, "url", localURL
end preOpenCard

Post Reply

Return to “iOS Deployment”