Adding a toolbar to UIImagePickerController

For an iPad app I was working on recently, I wanted to be able to show a toolbar on the bottom of a UIPopoverController which was being used to present a UIImagePickerController. It turned out this was a non-trivial problem to solve.

On iPad you are meant to display the image picker inside a popover. My first attempt was to ignore this and create a new view controller that had a main view and a toolbar. I added the image picker into to the main view and presented the whole thing in a popover:

UIImagePickerController *imagePicker = [UIImagePickerController alloc] init];
ToolbarPickerController *toolbarPicker = [ToolbarPickerController alloc] init];
[toolbarPicker.mainView addSubview:imagePicker.view];

UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:toolbarPicker];

This worked but was unsatisfactory for a few reasons:

  • The popover controller normally makes UINavigationController content look like its part of the popover itself (it styles the navigation bar, and any toolbars, to blend perfectly into the popover border). Because my new view controller was not a UINavigationController, but hosted one instead (UIImagePickerController), the popover did not apply the correct appearance.
  • The image picker thought it was modal and displayed a cancel button. It doesn’t do this normally when displayed in a popover. It was impossible to get rid of the cancel button and it was jarring. I also got a few warnings about a missing style while debugging.

In fact, this had not been my first attempt. Initially I had planned to simply add some toolbar items to the UIImagePickerController but gave up very quickly when this didn’t work. I decided to try again…but a bit harder.

My initial attempt had been to do something like this prior to displaying the popover:

imagePicker.toolbarHidden = NO;
imagePicker.toolbarItems = [NSArray arrayWithObjects…];

This doesn’t work, and its flawed. Firstly, the image picker forcibly hides the toolbar as soon as it presents anything. Secondly, the image picker is a navigation controller and therefore it sets its toolbar items from whatever view controller it is presenting. I wanted a consistent toolbar that would be visible all the time.

It turns out the solution is to show the toolbar and set the toolbar items on the top view controller every time the image picker presents a view controller. This can be achieved by implementing a couple of UINavigationControllerDelegate methods:

- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
  if (navigationController == self.imagePicker)
  {
    [self.imagePicker setToolbarHidden:NO animated:NO];
    [self.imagePicker.topViewController setToolbarItems:self.toolbarItems animated:NO];
  }
}

-(void)navigationController:(UINavigationController *)navigationController didShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
  if (navigationController == self.imagePicker)
  {
    [self.imagePicker setToolbarHidden:NO animated:NO];
    [self.imagePicker.topViewController setToolbarItems:self.toolbarItems animated:NO];
  }
}

You have to put the code in both methods. If you don’t, some transitions will hide the toolbar and it might not appear when initially displayed.

Guided Access in iOS 6

Improving fine motor control and having a blast

My son is autistic. Trying to explain what this means is very difficult. His autism means that at the age of four, among many many other things, he has no language, behaves very unpredictably and struggles with his fine motor skills. He is also the worlds biggest fan of Sound Blaster on the iPad.

A typical session finds him constantly distracted by three things:

1. The home button. It’s tactile and tempting and he just cant resist its constant allure.

2. Inadvertant use of multi-touch gestures or “fat fingers”. This always ends up throwing him out of the app.

3. On the iPhone, the Ad banner gets mistakenly hit. Again, taking him away from the action.

It is remarkable that for a boy who could not even understand his own name a few months ago, he is still able to navigate back to the app from any of these eventualities. This is because he knows that the home button will get him back to a known location, from which he can navigate back to the app.

One button.

Genius.

My wife is a teacher. She teaches small children of about 6 years of age and is just starting to use the iPad in the classroom. Trying to keep kids engaged on one task and ensuring they dont change all your settings when your back is turned is an issue all teaches and parents have to contend with.

With Apples latest update to iOS these are problems that can now be addressed. iOS 6, launching in just a couple of months, has a new feature called guided access. This lets you disable physical buttons, such as the home button, lock out certain areas of the screen, thus disabling input and even prohibit activation of the devices motion sensors.

Such features ensure that teachers, parents and supervisors have a way to keep a kids focus inside of the app…or even on just a specific part of an app. For my 8-bit fanboy son this means that we can prevent him being thrown out of his favorite app in all three of the situations outlined above.

No doubt this will also prove to be a fantastic feature for restaurants (menus), kiosks (tourist information), display-only setups (show rooms) and various other task centric scenarios.

Fo me, this means the iPad will continue to be a useful learning device for my son and hopefully my home button might last that little bit longer before giving up the ghost.

iBooks for Kids: Inception

What if this book, or at least the images for it, were created completely on the iPad? It would give it a unique kind of flavour wouldn’t it?

Having taken a look at ‘book style apps’ on the App Store and the various types of eBooks available in the iBooks store, I became interested in how you might go about developing one. Having ruled out plain old eBooks I was left with the following two choices:

  1. Develop an app which woud let you completely control the user experience but not be visible in the iBooks store.
  2. Develop an iBooks 2.0 ‘eBook’ and work within the fairly rigid constraints of the authoring tool.

Well, I’ve done apps. And it may well be the better option…but I fancied trying something new.

Now, I am not the greatest artist in the world. But I do like to play around with Sketchbook Pro on my iPad from time to time. This lead me to wonder…

What if this book, or at least the images for it, were created completely on the iPad? It would give it a unique kind of flavour wouldn’t it? And what if we leveraged HTML5 widgetry to create something a bit different to the non-app books that are out there at the moment?

I was mulling this over when something else was bought to my attention. An amazing-musician-and-producer friend of mine had recently recorded a nursery rhyme album…interesting. Now, I thought, that would be cool: A touchy, interactive, sing-along iBook for kids, with illustrations done all on iPad…and all self published.

So. That was that.

I’m currently working on the illustrations for the book. It’s going to be a pet project for a while. Hopefully I’ll finish it before I get distracted or swamped by other stuff.

It could be a fun and unusual journey.

iBooks for Kids: Confusion

A while ago I blogged about a silly little iPad app I wrote for my three year old son, and how it led me to wonder about iBooks.

It struck me that an app that was essentially a book that played sounds, and perhaps had a few animations, would make more sense as an iBook. Especially as we now have access to the iBooks 2.0 platform which supports rich media content and has an easy to use authoring package.

So I wondered. And I looked. And this is what I found out.

Existing iBooks for kids are boring and overpriced.

  • Most stuff already out there uses iBooks pre version 2.0. This means you get a pretty basic eBook with pictures. A very few support sound and even some animation but it is a far from engaging experience.
  • The use of a standard eBook is a bad fit. The pages in kids books are often oddly sized and require lots of space for illustrations; you dont want simple text wrapping. As such, by default you will find that quite often the pages scroll from left to right as you flip the page, which is a pretty bad user experience. You can make both pages of a double page fold fit on the screen but you lose any sense of involvement and the book becomes letter-boxed and lost in the unused screen space.
  • Many publishes offer iBook versions of their paper counterparts. They are digital copies, plain and simple. Considering they offer such a bad experience its surprising that they are actually the same price as the printed media. One book in ‘real-life’ was a touchy-feely cloth book for 0-3 year olds with just 5 pages. Its iBook equivalent was still £4.99 yet its main function (texture) was obviously non existant!

The App Store is not the right place for books

  •  If you are looking for an engaging kids book in the real world you go to a book store, or at least the book section in a toy store. In the world of iPad it makes sense that people should go to the iBooks store but not necessarily the App Store.
  • But the iBooks store is newer than the App Store and its not installed by default. Yet.
  • Because the App Store is just there and because apps offer limitless possibilities for the user experience, many compelling kids books can be found on there. Except they are not books. They are apps. It just isn’t…quite…right.

iBooks 2.0 still isn’t a perfect fit

  • When you start to explore iBooks 2.0 and iBooks Author one thing becomes apparent: It was designed for text books. This should come as no surprise given the marketing push…but for me at least, it did. I was surprised to find that it so rigidly organises everything into chapters and sections. It does this to such an extent that the only kids books that I found that did use iBooks 2.0 have had to work around it.
  • Expecting kids to get the ‘pinch into and out of a chapter’ gesture is unrealistic. At least for small children. As a workaround the books I saw used a single iBooks chapter with a single section and titled various pages in that section “chapter 1″, “chapter 2″ etc.
  • There is no page flip animation. Sad. But probably more practical for tiny hands.
  • Landscape is where it’s at. Although iBooks Author supports both orientations, you are confined to landscape for navigation; portait is an optional extra.
  • There are still relatively few built in ‘widgets’. Because it is geared towards text books, if you want something a bit different you will need to write some code. Specifically you will need to create some HTML5 widgets in dashcode.

Conclusion

iBooks Author for iBooks 2.0 is the best there is. But it is still not as good as developing an app…and you will need to work around several issues. However, as iBooks continues to grow it seems like it should be the place to look for these kind of books that are heavy on rich media and…well, fun kid stuff.

I wonder then. If you want to create a compelling kids book that will be found by parents who are searching for such things: Do you create an app or a iBook? Do you need a developer or a publisher?

I think maybe its time to find out.

 

iBooks for Kids: Conception

I have been using the iPad to read on more and more lately. Maybe it was because of my new found love of the Kindle app, or maybe it was because I just wanted a chance to experiment with UIPageViewController…I’m not sure, but I decided to build my 3 year old his very own app.

He loves anything that makes loud sounds, flashes on and off and generally annoys the hell out of most normal people. In-particular he likes these infuriating books that have a single plastic button and play the same jingle over and over again. They are infuriating, in-part because of the sound, but primarily because the button is a single moulded enclosure such that when the battery dies you have to buy an entire new book!

So, after going through three copies of “row row row your boat”, and not wanting to add, yet again, to the growing pile of cardboard and plastic, I decided to turn all of his books (he has pretty much the whole series) into a single app.

Some scanning, a bit of coding and a few hours later I had an app that let you push the button and turn the pages, all courtesy of UIPageViewController and AVAudioPlayer. And best of all, when the battery runs out you can plug it into the mains and recharge it!

But that was just the start…

It struck me that maybe my approach had been wrong. After all, Apple had recently released the iBooks 2.0 platform with iBooks Author. It was designed specifically for rich media books. So maybe that was a better option? Maybe I could have got it all done with even less effort and produced something with even better results.

I looked into it. I became confused.

I’m going to follow this up with a post very shortly about what I found out and what it lead to. But right now, I need to go and draw a tree, and a spider, and a bird…and about half a dozen other things. I’ll tell you why shortly.