Brian Long Consultancy & Training Services
Accompanying source files available through this
If you run any of your applications in the iPad Simulator they won’t look like they fit in very well as all our windows and views have been hardcoded to fit to a resolution of 320x480. If you want an application to run on the iPad then you really ought to design it for the iPad and the various features it offers, not least of which the 1024x768 screen resolution.
If you start with the project templates available in the iPad or iPad Storyboard section of MonoTouch's new solution dialog then your UI will be sized sensibly. On the other hand, the projects in the Universal and Universal Storyboard section of the dialog cover both options by having two nib files, one for the iPhone resolution and one for the iPad resolution. However you choose to go, there is support for the iPad.
If iPad is a valid target for your application you should also explore the various project options available (right-click on your project in the Solution window and choose Options), especially on the iPhone Build and iPhone Application pages.
This article won't be going into the specifics of iPad programming but it’s safe to say that all the techniques we’ve looked at thus far are perfectly applicable to programming an iPad application. However with regard to launch screens there are various different files required to cater for the different orientations the iPad application may be started in. You can find full details in this blog post.
There are three places that an icon is used in iOS: the Home screen, the Settings screen and the Spotlight (search) screen. Each of these places may require an icon of different dimensions. Depending on what devices you are targeting you may have to consider additional dimensions of each image again as iPhone 3 and iPod Touch use one set of resolutions, iPhone 4 uses another and iPad uses yet another.
In the simple case of targeting iPhone 3 and iPod Touch you would include two image files for these icons. Icon.png (57x57) is used on the Home screen and Icon-Small.png (29x29) is used on the Settings screen and also on the Spotlight screen.
If you were building a Universal application targeting all iOS devices then you would need to include all these icon files:
|File name||Image dimensions||Purpose|
|Icon.png||57x57||iPhone/iPod Touch Home screen|
|Icon@2x.png||114x114||iPhone 4 Home screen|
|Icon-72.png||72x72||iPad Home screen|
|Icon-Small.png||29x29||iPhone/iPod Touch Spotlight and Settings, iPad settings|
|Icon-Small@2x.png||58x58||iPhone 4 Spotlight and Settings|
Unlike the launch screen image these icons are not automatically used by iOS. Instead you have to specify the root file name in an entry in your project’s Info.plist file. This is an XML Information Property List file processed by iOS to set things up correctly for your application.
Fortunately, MonoTouch 5 understands the content of this Property list file and makes things much easier to deal with than working with the native OS X property list editor. Double-clicking on Info.plist in the Solution window opens up a simplified option selection UI, much the same as what we saw in the project options dialog earlier.
In the case of the App Icons and Splotlight/Settings icons the files needn't be named as per the specifications above (MonoDevelop will ensure things are set up correctly during the build process), but they must already be copied to the project's main directory and added into the project. Once that is done you can then use the icon selection options to choose each appropriate, and MonoTouch will update the Info.plist file as required.
Note: Requiring the icons to already be part of the project before selecting them, but allowing splash screens to be selected from anywhere is inconsistent and considered a bug. There is an open bug report on this, so it may get changed in the future.
The web services example contains the iPhone and iPhone 4 icons and also has a customized display name on the Home screen thanks to one of the project (or Info.plist) options. In the iOS Application Target sectiopn of the Info.plist options, the Application name value controls what text is written under the icon on the Home screen.
When running MonoTouch applications in the iOS Simulator from MonoDevelop you have access to a very capable debugger in the MonoDevelop IDE. It has the usual features of breakpoints, stepping into calls, stepping over calls, watches, local variables, call stack, thread information etc. All that is needed is some time to get used to where the windows and controls are and what shortcuts are available.
Some important things to note, however, include the fact that when debugging an application it takes up much more space than a release version and will be much slower due to the way debugging is implemented.
Additionally you need to take care when trying to debug code that executes during
the application startup process, for example in your main view controller’s
method or the App Delegate’s
FinishedLaunching() method. iOS keeps
an eye on an application as it starts and checks to see it makes it past startup
to be usable by the user in a timely fashion. If it gets held up in the startup
process for more than 10-20 seconds iOS will assume the application has hung and
so will kill it. So if you place a breakpoint in one of those startup methods, you
get very little time to debug anything before the application is removed before
your very eyes.
To debug code in the main view’s startup methods, consider making it a secondary
view launched from a button on a temporary main view. Alternatively use the very
common process of logging information to the Application Output window in order
to track down your bug. Calls to
Console.WriteLine() get listed in
the MonoDevelop Application Output window and this proves to be a very handy tracking
Go back to the top of this page
Go back to start of this article