Circling back on iOS

Having completed the fairly comprehensive iOS online course offered by Stanford on iTunes U, and having completed ColorMyWorld as my “final project”, it’s time to circle back on some important topics that I haven’t covered yet or only skimmed the first time around:

  • Unit testing
  • Memory management that’s not ARC (i.e. pre-iOS 5)
  • Reading the Apple Human Interface Guidelines
  • Fully understanding the app submission process: certificates, provisioning profiles, etc.

There’s so much more I want to learn, though:

  • Core Graphics (Quartz)
  • Core Animation

But then even apart from iOS, there’s a desire to explore other topics: web, deeper CS theory and mathematics, etc. Too many paths, not enough time and energy to explore them all.

ColorMyWorld app submission

I managed to submit and upload ColorMyWorld to the App Store on Friday. It took longer than expected to put the finishing touches on it.

iAd Integration

The last-minute iAd integration was trickier than it should have been because the best practice for iAd integration changed in iOS 6, and most of the googleable resources on it are iOS 5 and below. Thankfully, the iAdSuite sample project that Apple created shows the most important parts:

  • Use a single central delegate object to manage the ADBannerView. The sample code uses a BannerViewController class that’s instantiated in application:DidFinishLaunchingWithOptions: and sets that as the root controller.
  • The BannerViewController class is a container VC. It wraps a content view controller — in ColorMyWorld’s case, a navigation controller on iPhone and a split view controller on iPad — by adding it as a child VC, along with the ADBannerView. This is done in its loadView method.
  • In BannerViewController’s viewDidLayoutSubviews method, it creates the appropriate frame for ADBannerView by calling
    [bannerView sizeThatFits:self.view.bounds.size];
  • Once the ad banner view is sized properly, we can adjust the content view’s frame so that both fit together comfortably

The problems I ran into were:

  • At first I tried using the ad banner view that you drag out from XCode. Getting it to resize on device orientation changes was a bit of a hot mess. In retrospect, I wonder if I could’ve just called sizeThatFits: on it, but I think to do so it needs the iOS 6 method of initialization (initWithAdType:ADAdTypeBanner), which I’m not certain that it does if you drag it out from XCode.
  • I was trying to not modify the app delegate to get this working. I tried to create the BannerViewController in the storyboard and set it as the root VC, but then I wasn’t certain how to get it to load my custom content VC. In retrospect, I could probably do this by modifying BannerViewController to expose its content VC as a public outlet, then create a subclass that would load my custom content VC on initialization (would probably have to be in an init method rather than viewDidLoad).

One suggestion from Apple that I did not implement is to remove the ad banner view from the view hierarchy when the ad banner won’t be on screen for a while. The idea is that you don’t keep it around when the ad isn’t viewable so that ads aren’t wasted. In ColorMyWorld, this occurs when the UIImagePickerController is presented modally on the iPhone.

The reason why I chose not to implement this is because I’m still considering whether users will spend enough time taking, selecting, and editing pictures to justify doing this. If I was to implement this, I would need to extend BannerViewController to be able to remove and re-add its banner view via some public method call. The child content controller would call this by accessing its parent controller.

iPad

And for some silly reason, I decided last-minute to implement iPad support. I had to dig up some of the slightly-decaying knowledge of split-view controllers. Setting the master and detail VCs, the weird detail about having to implement the delegate method that says, “DO NOT HIDE MY MASTER VC.” I had to test some unforeseen user workflows, since many of the screens that are presented full-screen modally on the iPhone are not on the iPad. Oh, and I had to think about implementing a popover for the first time.

Most challenging, however, was some weird behavior I noticed in one particular use case where a user taps the Photo Library button before tapping the Camera button. The camera would end up displaying just short of full-screen, with a gap where the status bar would be, and the camera controls at the bottom shifted and clipped by the same gap. Weirdly enough, closing and opening the camera again would get rid of this behavior.

I tried everything. At first I thought it was some weird interaction between the UIImagePickerController and the UIPopoverController — maybe displaying the photo library in the popover caused it to get confused when I then asked it to display the camera mode, and it didn’t update its frame properly? Maybe I had to dismiss the image picker when the user dismissed the popover. Maybe I had to set the modal presentation style to full screen before displaying the camera?

Nope. Nothing.

In the end, the only solution was to set the UIImagePickerController to nil when the user dismisses the popover, which then causes a fresh instance to be created when the user picks the camera again.

Very, very weird behavior.

App Store Assets

Another pain in the neck was creating all of the art assets required for App Store submission. Icons of every different size, and screenshots to use as launch images. I had to fire up GIMP for the first time in a while. It was a bit tedious creating screenshots for each device.

App Store Hoops

And finally, the actual submission process on iTunes Connect is extremely jargon-y, complex, and confusing for a noob like myself. You create an app record, which requires that you enter your app’s Bundle ID, and there’s a SKU you create, and that creates an App ID, and you have to provision a distribution profile, and once you associate the App ID with the distribution profile, then you create an archive, and then you test the archive, and oh my god what is going on.

I managed to limp through it. I’m not 100% certain I did it right, nor do I fully understand what’s going on, but I most certainly will circle back to it next time and try to figure out what’s going on. At least this time I’ll know a little more what I’m getting myself into.