revUp - Updates and news for the Revolution community
Issue 101 | Dec 10th 2010 Contact the Editor | How to Contribute

New Features in LiveCode iOS
LiveCode with full iOS support has now officially launched

by Hanson Schmidt-Cornelius

LiveCode with iOS support has now launched, and it is packed with a whole range of exciting features that can be included and used in your applications. Full iOS support is now integrated in LiveCode 4.5.2, released Monday 6th December.

AppsWorld

Demonstrating LiveCode at Apps World

We demonstrated some of the new features during the Apps World Exhibition in London last week, and the positive response was overwhelming. The look and feel of writing and deploying applications fits right into the familiar development environment you have become used to from LiveCode. So, what's new in 4.5.2?

You now have the iOS deployment option in addition to the existing standalone deployment options. iOS deployment comes with a number of platform specific configurations. These include adding files you may wish to add to your bundle or selecting plist options that allow you to target your application for specific hardware devices and settings.

Mobile devices are the future, and with our entrance into this market, we have extended the IDE to include a Simulate button in the LiveCode menubar. This allows you to link directly into a variety of simulator versions provided by Apple. The button is enabled for any stack that is configured for iOS deployment. Applications can be written in the familiar way and then tested with a click of a button, before deploying them to the devices of your choice, including iPhone, iPod Touch and iPad. You have to enroll on the Apple iOS Developer Program before being able to test your applications on a real device. Membership on this programme is an Apple requirement and allows you to generate the necessary certificates and profiles.

For help getting up and running with the Apple Developer Program and building your iOS application, visit this lesson.

In addition to supporting many of the desktop features, LiveCode iOS supports many iOS specific features that you can normally only access when developing your applications in Xcode.

Features

The current release of the iOS engine is based on a stable 4.0 branch that provides you with a robust framework for your iOS applications. It also means that not all of the features present in the 4.5.x engine are available to the current iOS platform. Work to bring these engines together into one stream is underway.

The following features do work in iOS:

  • Rendering of controls with non-system themes. (Motif is the default theme, and you can quickly and easily create beautiful, custom skinned applications)
  • Date and time handling
  • Gradients, graphic effects and blending
  • Any non-platform, non-system dependent syntax, for example maths functions, string processing functions, behaviors etc.

iOS Specific LiveCode Support

In order to provide users of iOS applications with a familiar look and feel of the applications you write, LiveCode supports many features that are normally only accessible via Xcode. This includes:

  • Springboard icons and launch image support
  • Bitmap and vector graphic support
  • Button and text field support
  • Status bar configuration support via the plist or programmatically
  • iOS inertial scrolling
  • iOS pick wheels
  • Orientation change handling
  • Multi-touch support
  • Shake motion detection
  • Accelerometer support
  • Access Core location
  • Gesture support
  • Audio playback
  • Video Playback
  • Visual transition effects
  • Webkit Web browser object
  • Text and data processing support
  • HTTP, FTP & POST
  • Send mail

The following 4.5.x features are currently not supported in iOS:

  • Clipboard related syntax and functionality
  • Printing syntax and functionality
  • Socket syntax and functionality
  • Audio clips/video clips/player functionality. You can use the 'play' and 'play video' syntax instead
  • Externals cannot be loaded

We will be adding support for these features in a number of forthcoming updates to this platform.

LiveCode Browser Control

The ease with which iOS applications can be developed in LiveCode is remarkable. Take the following example that demonstrates the key points of how to implement an iPhone based web navigator. This example incorporates key features that you would expect to find in most web browsers or navigators. A detailed lesson on implementing this web navigator can be found in the LiveCode Lessons for Mobile Devices here.

As with many LiveCode applications, start developing this navigator by dragging and dropping the controls onto a card. This should include buttons to navigate to previous and next pages. You should also add buttons that allow you to stop loading a page and refresh the content of an existing page. Also create a text field for the URL, a label in which to display load status information and a group to present the content that is being downloaded from the Internet. The interface can be created without writing code and may present you with a navigator prototype that looks something like this:

prototype

Next add code to the mouseUp events of the four buttons:

on mouseUp
   doAction "retreat" // for the previous
end mouseUp

on mouseUp
   doAction "advance" // for the next button
end mouseUp

on mouseUp
   doAction "stop" // for the stop button
end mouseUp

on mouseUp
   doAction "reload" // for the reload button
end mouseUp

Add code to the closeField and returnInField events of the text field:

on closeField
   goUrl the text of me
end closeField

on returnInField
   focus on nothing
end returnInField

The remaining code should be place on the card of the application. This code ties the input from the buttons to actions that are submitted to web pages, updates the status bar and displays the web content in the display group.

# declare the local id of the browser we are creating
local sBrowserId

on preOpenCard
   # quit if we are not on a mobile device
   if the environment is not "mobile" then
      exit preOpenCard
   end if
   
   # create the browser
   iphoneControlCreate "browser"
   put the result into sBrowserId
   
   # set up the basic defaults
   iphoneControlSet sBrowserId, "rect", the rect of group \
          "Browser"
   iphoneControlSet sBrowserId, "visible", "true"
   iphoneControlSet sBrowserId, "url", "http://www.runrev.com"
end preOpenCard

on closeCard
   if the environment is not "mobile" then
      exit closeCard
   end if
   
   # destroy the browser we created
   iphoneControlDestroy sBrowserId
end closeCard

# provide a status message that indicates loading has started
on browserStartedLoading pUrl
   put "Started loading:" && pUrl into field "Status"
end browserStartedLoading

# provide a status message that indicates loading has finished
on browserFinishedLoading pUrl
   put "Finished loading:" && pUrl into field "Status"
   put pUrl into field "Url"
end browserFinishedLoading

# provides a status message that indicates the reason for loading
on browserLoadRequest pUrl
   answer "Do you want to load:" && pUrl with "Yes" and "No"
   if it is "Yes" then
      pass browserLoadRequest
   else
      put "Refused:" && pUrl into field "Status"
   end if
end browserLoadRequest

# a handler that executes an action invoked by the controls
on doAction pAction
   iphoneControlDo sBrowserId, pAction
end doAction

# a handler that loads the URL
on goUrl pUrl
   iphoneControlSet sBrowserId, "url", pUrl
end goUrl

The simulator demonstrates what the web navigator could look like when deployed on a physical device.

I hope you have found this article interesting, you can download the full release notes for 4.5.2 here. We look forward to bringing you more features and improvements as we continue to develop LiveCode for iOS.

Hanson Schmidt-Cornelius

About the Author

Hanson Schmidt-Cornelius is an experienced software developer with an interest in artificial intelligence.

 

Main Menu

What's New

Use Coupon
XMASMARKET
for 10% discount on any Marketplace purchase