Planet iDev tweak

March 4th, 2010 § 0

Some of the articles included by Planet iDev were getting pretty long, so I’ve decided to display just excerpts of the posts on the website rather than the entire articles. The RSS/Atom feeds should still have the full text.

Some of the excerpts seem to be showing up empty. I’m not 100% sure of what is causing that, but I’ll look into it (I made some changes to FeedWordPress, so it’s likely something I did :)

Thanks!

Planet iDev

January 31st, 2010 § 1

When I was doing more Flash development, one of the most valuable web resources I used was Adobe Feeds. It aggregates many, many Adobe-oriented developer blogs from all over the web. Not only is it a great place to keep an eye on the pulse of the Flash development world, but it’s where smaller Flash developers can get more exposure to more of the community. Thanks to my own blog’s inclusion in Adobe Feeds, I was able to get some answers to some Flash questions more quickly than I probably would have otherwise, all while sharing what knowledge I had to as broad an audience as possible.

When I started doing iPhone development, I looked for something similar for iPhone dev blogs. While there are a lot of iPhone developers out there blogging, I could not find a good aggregator out there. I did find Planet iPhone SDK, but it does not seem to be active (I tried contacting the owner, but did not receive a response). Planet Cocoa is good and quite active, but iPhone development is just part of the coverage there (the rest is Mac desktop development, which I don’t do myself).

Thus, I am starting Planet iDev. Armed with FeedWordPress and a free WordPress theme, I have cobbled together a simple blog aggregator. I should note that many of the blogs I am aggregating I found on this tremendously helpful post by Travis Dunn.

Having never run a blog aggregator before, I am unsure of the ethics and etiquette of Planet-style sites. I have no intention of financially profiting from other people’s hard work, nor do I want to negatively impact others’ endeavours. With that in mind:

  • There will never, ever be ads on Planet iDev
  • All authors are credited, and all articles link back to their original sources (as do all of the items in the Planet iDev feed).
  • I have set up the WordPress install to not be indexed by search engines.

Regardless, if any blog owner wants to be removed from this aggregation, I will be more than happy to do so, and I offer my sincerest apologies.

On the other, if any iPhone developer out there wants their blog to be added to this Planet, simply email me at planetidev@gmail.com (or comment on this post) with your blog’s information, and it will be considered for inclusion. Preference will be given to blogs that focus on the development and production process, rather than blogs that are mostly for product promotion.

I still have some questions regarding Planet etiquette. While most Planet sites seem to include the entire contents of the aggregated blogs’ posts, I wonder if it would be more polite to only display an excerpt (but include the entire article in the feed). Please share any thoughts you have on this matter, or on Planet iDev in general.

I hope others out there find this resource valuable and useful, and I hope this helps encourage a sense of community. Thanks!

Visit Planet iDev.

iPhone offline web applications: tips and gotchas

January 24th, 2010 § 0

I spent this evening updating my “iPhone VR” Javascript/CSS demo to work with iPhone OS 3.0 (it had stopped working 100% correctly since the OS update). I also decided to spend some time making it work as an offline-capable web application.

The basic process of making your web app cacheable offline is, in theory, fairly straightforward, and generally well-documented at Apple’s website. I ran into some interesting headaches though.

Gotchas:

  • First thing to note is that your web server must serve your cache manifest file with a MIME type of text/cache-manifest. This may mean editing mime.types to add a line that looks like this:
    text/cache-manifest   manifest

    or perhaps a line in httpd.conf that looks like this:

    AddType text/cache-manifest  .manifest
  • The next thing that had me stumped for a while: while your web server may know how to take the URL http://example.com/webapp/ and automatically and invisibly serve up the file http://example.com/webapp/index.html, your offline web app knows nothing of this mapping of webapp/ to webapp/index.html. If the URL bar reads http://example.com/webapp/ and you save it locally using a home screen bookmark, it will fail to launch correctly if the device is offline, even if index.html file has been cached. The device simply does not know to look for webapp/index.html instead of webapp/. Thus, you must ensure that the URL bar reads webapp/index.html before the user makes a home screen bookmark.
  • At first, I thought I would enforce the above with a tiny bit of JavaScript that simply reads window.location and redirects to window.location + "index.html" if the URL ends in a slash. This worked while online, but it broke my app when offline, even when the redirection was not taken. Why? It seems that any reference to window.location in your script is treated as network access. Since the device is offline, it generates an error alert.

    Instead, I made my app live at webapp/main.html, and created a small webapp/index.html file that simply redirects to main.html. (I could have used a server redirect inside of an .htaccess file instead, but I chose not to, for no particular reason.)

Tips:

  • You can specify a custom icon for the home screen bookmark using a <link> element, like so:
    <link rel="apple-touch-icon" href="custom_icon.png" />

    If you don’t want iPhone to automatically apply the “shine” effect on your icon, use the following instead:

    <link rel="apple-touch-icon-precomposed" href="custom_icon.png" />
  • Since iPhone OS 3.0, offline web apps can have custom splash screens, just a like a native app! Simply add a link element to your web page:
    <link rel="apple-touch-startup-image" href="/splash.png" />

If you want to see the results of all this, go to http://bunnyherolabs.com/iphone/xform/ on your iPhone or iPod Touch, then click the “+” (add bookmark) button and choose “Add to Home Screen.” Now you can click on the “Panorama” icon on your home screen to see the demo at any time, even when not connected to the internet.

Easter egg in your iPhone app? Don’t hide it from Apple

October 21st, 2009 § 0

Yesterday, when I logged into the iPhone Dev Centre, I was greeted with a “please agree to the new developer agreement” alert. As usual, I copied the text and diffed it with the previous version. The bulk of the changes had to do with allowing in-app purchases in free apps.

But the following change caught my eye: in section 12.2, “Termination”:

12.2 Termination
This Agreement and all rights and licenses granted by Apple hereunder and any services provided hereunder will terminate, effective immediately upon notice from Apple:

(f) if You engage, or encourage others to engage, in any misleading, fraudulent, improper, unlawful or dishonest act relating to this Agreement, including, but not limited to, misrepresenting the nature of Your submitted Application (e.g., hiding or trying to hide functionality from Apple’s review).

(emphasis added)

So be careful, hidden-unlockable-feature-mongers. Apple could terminate your licence!

Genesis^H^H^H^H^H^H^H Droid Does

October 18th, 2009 § 0

Verizon’s hard-hitting “Droid Does” anti-iPhone ad (via TechCrunch):

I love my iPhone (and developing for it) but I definitely would like to see more competition in this space. I think this ad hits home for those of us who are frustrated with the iPhone’s shortcomings. On the other hand, the style of the end of the video makes me think of trailers for horror movies. I’m not sure that’s such a good association to make!

This ad campaign also reminds me of the old Sega Genesis commercials back in the day:

Flash and iPhone

October 11th, 2009 § 1

It’s been a few days now since Adobe announced that Flash CS5 Professional will have a “publish for iPhone” feature for ActionScript 3 projects. Just wanted to jot down a few thoughts:

As a Flash developer and geek, the technology seems pretty damn impressive to me. It actually includes the LLVM compiler? Wild.

Still, there are technical concerns, although to be fair, there are many months before CS5 ships. And for the moment, Flash-built apps won’t have access to things like the iPhone’s native UIKit controls, but they will have access to the accelerometer and multitouch (which at first I thought they did not).

Furthermore, as an iPhone developer, I have concerns, and in a way these concerns have less to do with Adobe’s actions than Apple’s: the single chokepoint that is the App Store and its review/approval system. It’s clear that Apple’s review system does not scale (longer and longer delays in approvals), and discoverability is bad enough as it is with the number of apps in the store now and the limited number of ways there are to browse and find things in the store.

If the iPhone app ecosystem was completely open, with many “stores” and multiple ways of finding and buying apps, I’d welcome Flash-built iPhone apps with open arms: the more the merrier. As it is, though, I worry a bit about the flood of muck as every Flash developer (over a million by Adobe’s count: A MILLION!) with a back catalogue of content tries to get their old code into the App Store.

Some obvious predictions:

  • We’ll see more than a few Flash component libraries that emulate UIKit controls
  • Apple will unofficially delay or reject Flash-built apps for the first while until/unless Adobe and Apple come to some kind of understanding (see the issues that PhoneGap apps have had in the past, and that uses all native SDKs!).
  • Flash developers will find it more difficult than they expect to get their old code working well on the iPhone
  • Many iPhone programming contracts will be lost as clients decide (correctly or incorrectly) that they can do their iPhone project in-house with Flash

Still, I have to admit I personally can’t wait to get my hands on the public beta of Flash CS5. I enjoy working with Flash and ActionScript.

Another UITabBarController change from 2.x to 3.0

July 22nd, 2009 § 0

Or actually with UITabBarControllerDelegate, and specifically, with the method tabBarController:didSelectViewController:.

According to the docs, the differences:

OS called only when
tab changes?
called when changed
programmatically?
before OS 3.0 YES YES
OS 3.0 and later NO NO

If you are writing code that runs on both 2.x and 3.0 that needs to get tricky with tabs, these changes are a nuisance.

Even more infuriating is that the Apple documentation isn’t complete. The section ends with the sentence fragment “If you are implementing….” Yes? If I am implementing what? And what do I do if I am?

Yes, I’ve already reported documentation error. No response though. My guess is they’ll just remove the sentence fragment instead of expanding on it :(

[edited: I made a mistake in the table the first time I posted this. Should be fixed now.]

Approved!

July 11th, 2009 § 0

I forgot to mention that my apps (two versions of the same app: a free, ad-supported one, and a 99-cent ad-free version) were approved this past week on the iPhone App Store!

Please check out My Monkey.

Time from submission to approval: 13 days.

It’s a simple app, an Objective-C port of my Flash monkey widget. I added support for multitouch, the accelerometer and custom image backgrounds chosen from the user’s photo library.

It was a pretty straightforward port. The main thing I had to get used to again (coming from ActionScript) was the lack of automatic garbage collection.

I don’t expect this app to tear up the charts or anything like that :) but mainly as an exercise in learning iPhone programming and the whole process from code to distribution.

UITabBarController timing change from OS 2.X to 3.0

June 29th, 2009 § 1

This is just a short note about a change I discovered between iPhone OS 2.x and 3.0. It’s not very interesting or exciting but I thought I’d record it in the off chance that it helps someone else.

When the user switches tabs on a UITabBarController in iPhone OS 2.x, the sequence of events is:

  1. UIView of new tab gets added as a subview
  2. UIView of old tab gets removed
  3. The delegate’s tabBarController:didSelectViewController: method is called

Run the same code on iPhone OS 3.0, however, and the sequence is this:

  1. UIView of new tab gets added as a subview
  2. The delegate’s tabBarController:didSelectViewController: method is called
  3. UIView of old tab gets removed (sometime later, I think it’s invoked via one of NSObject’s performSelector: methods)

This is a inconsequential change for most, but it might make a difference if you are checking the UIViews’ superview variables in your tab bar controller delegate method.

UIImagePickerController cropRect seems to be useless?

June 6th, 2009 § 12

[UPDATE: In iPhone OS 3.0, the cropRect behaves more consistently (even if it's still a little odd), see Stormy Productions' Image Picker Sample, which works perfectly in 3.0. This article only applies to 2.2.1.]

I am using UIImagePickerController to let the user choose an image from their photo library, and allowing image editing (move and scale).

When the user is done moving and scaling, the OS calls my UIImagePickerControllerDelegate’s didFinishPicking method with information about the original image and the cropping rect in editingInfo.
move and scale
One might think that the cropping rectangle returned by the UIImagePickerController would be in the coordinate system of the original UIImage, since that would make the most sense. One would be wrong, however. Based on my own experiments on my iPhone and various threads on Apple message boards, it seems that sometimes the cropping rectangle is based on a 640×480 image (that is: the original photo is first resized to 640×480 pixels, and the cropRect is in the resized image’s coordinate system).

But not always! Screenshots taken on iPhone (using power button + home button), which are 320×480, have a cropRect based on the original image size.

So that’s easy to deal with then, right? Just compare the original image’s size to see if it’s 320×480 or not…

Not so fast. That does not always work. I have on my iPhone some 320×480 images that, when picked with the image picker, return cropRects that are in some weird coordinate system. An unzoomed (1:1) crop returns a width and height of 432×433! That would imply the image is scaled to 432×648 before cropping. Odd!

(Where did these images come from? Both of them were created by other iPhone apps, saving a 320×480 image to the photo library. UPDATE: it seems to happen with JPEGs of certain sizes/proportions. See my comments for sample images.)

Unfortunately, so far I have been unable to distinguish between these two types of 320×480 images in code. Without being able to get reliable info about the coordinate system of the cropping rect, the cropping rect is basically useless. (And no, you can’t just compare the cropRect to see if it’s 432 pixels wide :P Once you scale that picture in the image picker, the width could be anything, still in that weird coordinate system.)

If anyone has any code that reliably deals with all images (including images of arbitrary dimension [e.g 527 x 325] that are saved to the iPhone), at all zoom levels, please let me know :)

Where Am I?

You are currently browsing the iPhone category at bunnyhero dev.