My code is below (actually 2 samples put together):
Everything seems to work okay, but you select a photo sessionComplete never seems to get called, or if it does, nothing ever gets printed to the screen, etc… Any help is greatly appreciated, as I am not coming up with anything…
[lua]local bkgd = display.newRect( 0, 0, display.contentWidth, display.contentHeight )
bkgd:setFillColor( 0, 0, 0 )
local roundedRect = display.newRoundedRect( 10, 50, 300, 40, 8 )
roundedRect:setFillColor( 0, 0, 0, 170 )
local t = ui.newLabel{
bounds = { 10, 55, 300, 40 },
text = “Waiting for button event…”,
font = “AmericanTypewriter-Bold”,
textColor = { 255, 204, 102, 255 },
size = 18,
align = “center”
}
local showCamera = function(event)
–t:setText( "id = " … event.id … ", phase = " … event.phase )
media.show( media.Camera, sessionComplete )
–return true
end
local showPhotos = function(event)
–t:setText( "id = " … event.id … ", phase = " … event.phase )
media.show( media.PhotoLibrary, sessionComplete )
–return true
end
local sessionComplete = function(event)
local image = event.target
–display.newImage (image)
print( "Camera ", ( image and “returned an image” ) or “session was cancelled” )
print( "event name: " … event.name )
print( "target: " … tostring( image ) )
if image then
– center image on screen
image.x = display.contentWidth/2
image.y = display.contentHeight/2
local w = image.width
local h = image.height
print( “w,h = “… w …”,” … h )
end
end
–http://developer.anscamobile.com/reference/index/displaysave
–local savePhoto = function(event)
– local screenShot=display.captureScreen( true )
– screenShot:removeSelf()
–end
local cameraButton = ui.newButton{
default = “buttonBlueSmall.png”,
over = “buttonBlueSmallOver.png”,
onEvent = showCamera,
id = “cameraButton”,
text = “Camera”,
size = 12,
emboss=true
}
local photoBrowseButton = ui.newButton{
default = “buttonBlueSmall.png”,
over = “buttonBlueSmallOver.png”,
onEvent = showPhotos,
id = “photoBrowseButton”,
text = “Photos”,
size = 12,
emboss=true
}
cameraButton.x = 85; cameraButton.y = 300
photoBrowseButton.x = 250; photoBrowseButton.y = 300[/lua] [import]uid: 19193 topic_id: 5479 reply_id: 305479[/import]