Page 1 of 1
Universal IOS app
Posted: Sun Jun 19, 2011 8:41 pm
by ncmac
I am trying to create a universal (iPodiPad) app using two separate stacks. This is what I have tried (for several hours now) but it's not working. I appreciate anyone's help. Thanks!
on preOpenStack
getTheDevice
end preOpenStack
on getTheDevice
put the machine into tDevice
switch tDevice
case "iPhone Simulator"
case "iPhone"
case "iPod Touch"
go to stack "iPhonestack" --This is the substack
break
case "iPad Simulator"
case "iPad"
go to stack "iPadStack" -- This is the main stack
break
end switch
end getTheDevice
Re: Universal IOS app
Posted: Sun Jun 19, 2011 10:54 pm
by Jellicle
You are working too hard
Try a simple if...then statement, based on the device's screen resolution:
if item 1 of iphoneDeviceResolution() = "640" then -- iPhone Retina
if item 1 of iphoneDeviceResolution() = "320" then -- iPhone 3G/3GS
if item 1 of iphoneDeviceResolution() = "768" then -- iPad...I think...don't have mine handy
Gerry
Re: Universal IOS app
Posted: Fri Jun 24, 2011 1:21 am
by ncmac
Thanks. I have tried both ways (see below) and the correct stack isn't opening. I appreciate any help!
Version 1
on preOpenStack
getTheDevice
end preOpenStack
on getTheDevice
put the machine into tDevice
switch tDevice
case "iPhone Simulator"
case "iPhone"
case "iPod Touch"
go to stack "iPhonestack"
break
case "iPad Simulator"
case "iPad"
go to stack "iPadStack"
break
end switch
end getTheDevice
Version 2
on preOpenStack
if the environment is "mobile"
then
if item 1 of iphoneDeviceResolution() = "640" then go to stack "iPhonestack"
else
if item 1 of iphoneDeviceResolution() = "320" then go to stack "iPhonestack"
else
if item 1 of iphoneDeviceResolution() = "768" then go to stack "iPadStack"
end if
end if
end if
end preOpenStack
Re: Universal IOS app
Posted: Fri Jun 24, 2011 3:22 am
by jacque
Either detection method will work. Try waiting for the startup business to finish, and then go to the stack you really want.
Put these handlers in the CARD script of the first card of the main stack. That way they won't trigger when your substacks open.
Code: Select all
on preOpenStack
set the visible of this stack to false -- hide it
end preOpenStack
on openStack -- it's still invisible
getTheDevice -- your substack opens here; it is visible
end openStack
I don't see any provision for the desktop IDE, so "getTheDevice" won't do anything of course if you aren't running it in a mobile environment.
Also note that after this runs once, the mainstack will be invisible forever if you save the stackfile. Use the Application Browser to see it again if you need it.
Re: Universal IOS app
Posted: Sat Jun 25, 2011 7:00 pm
by ncmac
That worked. Thank you very much.
Re: Universal IOS app
Posted: Wed Jul 13, 2011 9:35 pm
by scotttyang
what is the script you are using to switch between stacks for iPad and iPhone. I am following this thread for mys scripting, but I just get a black screen on the actual iPad and iPhone
Re: Universal IOS app
Posted: Wed Jul 13, 2011 11:58 pm
by ncmac
Put this in the card script of the first card:
on preOpenStack
set the visible of this stack to false -- hide it
end preOpenStack
on openStack -- it's still invisible
getTheDevice -- your substack opens here; it is visible
end openStack
This is in the stack script
on getTheDevice
put the machine into tDevice
switch tDevice
case "iPhone Simulator"
case "iPhone"
case "iPod Touch"
go to stack "iPhonestack"
break
case "iPad Simulator"
case "iPad"
go to stack "iPadStack"
break
end switch
end getTheDevice
Re: Universal IOS app
Posted: Mon Aug 08, 2011 7:16 am
by SteveHanlan
I just kept one stack, but having detected the size of the screen. (in the PreOpenStack), if it's an iPhone, I directed to a different card
In this way I kept all my common code in the stack script , and all the size dependent code in the card script
Code: Select all
put the screenRect into myRect
if item 3 of myRect=1024 or item 4 of myRect=1024 then -- check both orientations
put "ipad" into gDevice
go to card "main"
else
if item 3 of myRect=320 or item 4 of myRect=320 then -- check both orientations
put "iphone" into gDevice
go to card "iphonemain"
else
put "desktop" into gDevice
go to card "desktopmain"
end if
end if
Re: Universal IOS app
Posted: Mon Aug 08, 2011 9:39 am
by Dixie
Hi...
It might help you to read page 37 of the iOS release notes, 'Runtime Environment Querying'... it explains how to determine both the processor or the machine that your stack is running on... for example, for you to determine what type of device you are running on this would help...
Code: Select all
on preOpenStack
switch the Machine
case "iPod Touch"
case "iPhone"
case "iPhone Simulator"
/* do whatever you want */
break
case "iPad"
case "iPad Simulator"
/* do whatever you want */
break
end switch
end preOpenStack
be well
Dixie
Re: Universal IOS app
Posted: Mon Aug 08, 2011 9:45 am
by Dixie
Oops sorry...
ncmac has already answered this... I didn't see his posting...
apologies..
Dixie