Universal IOS app

Getting into LiveCode for iOS? Ask your questions here.

Moderators: Klaus, FourthWorld, heatherlaine, kevinmiller, robinmiller

Post Reply
ncmac
Posts: 31
Joined: Thu Apr 27, 2006 10:29 pm

Universal IOS app

Post by ncmac » Sun Jun 19, 2011 8:41 pm

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

Jellicle
Posts: 448
Joined: Thu Feb 24, 2011 11:07 am

Re: Universal IOS app

Post by Jellicle » Sun Jun 19, 2011 10:54 pm

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
27" iMac, 27" Cinema Display, OS X Mavericks
iPhone 5 (plus a bunch of older devices for testing)
LiveCode Commercial license. Developer Program member.

ncmac
Posts: 31
Joined: Thu Apr 27, 2006 10:29 pm

Re: Universal IOS app

Post by ncmac » Fri Jun 24, 2011 1:21 am

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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 5926
Joined: Sat Apr 08, 2006 8:31 pm
Location: Minneapolis MN
Contact:

Re: Universal IOS app

Post by jacque » Fri Jun 24, 2011 3:22 am

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

ncmac
Posts: 31
Joined: Thu Apr 27, 2006 10:29 pm

Re: Universal IOS app

Post by ncmac » Sat Jun 25, 2011 7:00 pm

That worked. Thank you very much.

scotttyang
Posts: 125
Joined: Sat Jan 31, 2009 12:01 am

Re: Universal IOS app

Post by scotttyang » Wed Jul 13, 2011 9:35 pm

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

ncmac
Posts: 31
Joined: Thu Apr 27, 2006 10:29 pm

Re: Universal IOS app

Post by ncmac » Wed Jul 13, 2011 11:58 pm

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

SteveHanlan
Posts: 80
Joined: Fri Jul 09, 2010 6:28 pm

Re: Universal IOS app

Post by SteveHanlan » Mon Aug 08, 2011 7:16 am

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

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Universal IOS app

Post by Dixie » Mon Aug 08, 2011 9:39 am

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

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am
Location: Bordeaux, France

Re: Universal IOS app

Post by Dixie » Mon Aug 08, 2011 9:45 am

Oops sorry...

ncmac has already answered this... I didn't see his posting... :oops:

apologies..

Dixie

Post Reply

Return to “iOS Deployment”