Universal IOS app
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Universal IOS app
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
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
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
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
14" MacBook Pro
Former LiveCode developer.
Now recovering.
Former LiveCode developer.
Now recovering.
Re: Universal IOS app
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
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
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Universal IOS app
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.
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.
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
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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
Re: Universal IOS app
That worked. Thank you very much.
-
- Posts: 125
- Joined: Sat Jan 31, 2009 12:01 am
Re: Universal IOS app
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
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
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
-
- Posts: 80
- Joined: Fri Jul 09, 2010 6:28 pm
Re: Universal IOS app
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
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
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Universal IOS app
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...
be well
Dixie
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
Dixie
-
- Livecode Opensource Backer
- Posts: 1336
- Joined: Sun Jul 12, 2009 10:53 am
- Location: Bordeaux, France
Re: Universal IOS app
Oops sorry...
ncmac has already answered this... I didn't see his posting...
apologies..
Dixie
ncmac has already answered this... I didn't see his posting...
apologies..
Dixie