Flash and iPhone

October 11th, 2009 § 1 comment § permalink

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 comments § permalink

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 comments § permalink

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 comment § permalink

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 comments § permalink

[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 :)

BHColourPicker!

May 29th, 2009 § 0 comments § permalink

It’s generally usable now, so I’ve decided to release it, warts and all. I’ve created a Google Code project for it, bhcolourpicker, where ‘bh’ stands for ‘bunnyhero’ :)

It’s not particularly well-documented at the moment, but that will (hopefully) change.

Here’s an excerpt from the HowTo page on the project site:

To show the colour picker, use code something like the following:

    //  since it has 'new' in the method name, you own it...
    BHColourPickerController *vc = [BHColourPickerController newColourPickerController];
    vc.delegate = self;                    // the delegate
    vc.colour = self.view.backgroundColor; // the initial colour
    vc.titleText = @"Some kind of title";  // title to display
    [self presentModalViewController:vc animated:YES];
    [vc release];   //  ...and must release it

You must implement the BHColourPickerControllerDelegate protocol in one of your objects. Implement the following two methods (with examples):

- (void)colourPickerControllerDidCancel:(BHColourPickerController *)controller
{
    // the user just cancelled it; put the picker away
    [self dismissModalViewControllerAnimated:YES];
}
 
- (void)colourPickerController:(BHColourPickerController *)controller didFinishPickingColour:(UIColor *)colour
{
    // the user confirmed a colour; do something with it
    self.view.backgroundColor = colour;
    // and put the picker away
    [self dismissModalViewControllerAnimated:YES];
}

I’ve released it under a New BSD Licence. Share and enjoy!

Colour picker in progress

May 23rd, 2009 § 1 comment § permalink

This isn’t quite done yet, but I am working on a colour picker for iPhone. I plan to release it under the MIT Licence when I’m ready. I’m fairly shy about open-sourcing my code, I’m always embarrassed about the quality…

Till then, here’s a screenshot:
iPhone colour picker

Note to myself: OpenGL gotchas

May 10th, 2009 § 0 comments § permalink

Not so much “gotchas” as “got-me”s, probably. It’s been so long since I’ve done any significant OpenGL coding that I keep forgetting little things that result in a blank screen or a white texture :) Anyway, I thought I’d record them here to remind myself.

Note that I’m currently using OpenGL for 2D drawing.

  • Set glTexParameter for GL_TEXTURE_MIN_FILTER to something like GL_LINEAR before calling glTexture2D. The default value for GL_TEXTURE_MIN_FILTER is GL_NEAREST_MIPMAP_LINEAR, and if you’re not using mipmaps, the texture won’t draw!
  • I forgot that glOrtho manipulates the current matrix. Which means that if you don’t call glLoadIdentity beforehand you might not be getting the projection matrix you were hoping for!
  • This one was particularly boneheaded :P Make sure that the type parameter in glTexCoordPointer is actually the same type as the array! As in, if you pass in a pointer to an array of floats, make sure that the type parameter is set to GL_FLOAT. I blame this one on copy/pasting without paying enough attention.

Well that’s enough embarrassment for today. And I also just found this article: Avoiding 16 Common OpenGL Pitfalls, which looks useful…

EDIT: Just needed to mention another oversight that had me scratching my head for a while when things weren’t rendering as expected. Note the difference between the GL constants GL_TEXTURE and GL_TEXTURE_2D! Use the former for the parameter to glMatrixMode. Use the latter for enabling/disable texturing with glEnable/glDisable!

Too many monkeys! A newbie lesson about viewDidLoad:

March 23rd, 2009 § 0 comments § permalink

I recently learned another important newbie lesson about viewDidLoad: : it may be called multiple times during your application’s lifetime for any given UIViewController if its view is ever hidden and shown during low-memory situations.

Here’s the story: I am currently making a monkey app which features a single monkey. It was running fine in the simulator, but sometimes when I ran it on the device, an extra monkey was spawned every time I switched between the main view and the settings view! A couple of view switches and I’d have a bunch of monkeys onscreen, which was amusing but also very slow and not what was intended. Who was making the new monkeys?

My first iPhone test apps did a lot of initialization in viewDidLoad:. It makes sense because it is called right after a view has finished loading from its nib, and it feels like a good time to do your final initialization of things since the system has basically done everything it needs to do to display a window.

What I forgot was that the default behaviour of UIViewController didReceiveMemoryWarning is to release its view if it’s currently hidden (due to navigation, say). All well and good. But when the view becomes visible again, the view will be reloaded from its nib, and viewDidLoad: will be called again.

This is why I kept getting new monkeys: I was making the monkey in my MainViewController‘s viewDidLoad:. When I switched to the settings view when memory was short, the MainViewController purged its view. Switching back to the main view caused the MainViewController to reload the view from the nib, thus calling viewDidLoad: again, and thus creating another monkey.

So, any initialization code that goes into viewDidLoad: should make sense in that situation: i.e. view-specific stuff when recreating the UIView object, not application-level initialization stuff. Or, if your app-level initialization stuff needs a view to be loaded before running, then at least check to make sure that it hasn’t run already.

iPhone newbie lessons

March 20th, 2009 § 0 comments § permalink

It’s been a long time since I messed around with Objective-C, even a little bit.

A couple of things that have bitten me lately:

  • @selector(apply:) is different than @selector(apply)! Note the lack of a colon in the second one. The colon means that there is one parameter to be passed with the message. No colon, no parameter. This makes a big difference when passing a selector as an argument to something like NSArray makeObjectsPerformSelector:.
  • I keep forgetting to pass nil as the terminating argument to methods like NSArray initWithObjects:. Forgetting the terminating nil will cause the iPhone to crash with a Bad Access exception as it runs off the end of the stack into the weeds.

And one very valuable debugging tip I found here:
how to find out what exception was thrown in the Xcode debugger. When an uncaught exception kills your iPhone app, Xcode doesn’t really have much information at that point. To remedy that, go to Run -> Show -> Breakpoints and in the Breakpoints window double-click on the entry that says “Double-Click for Symbol.” Enter “objc_exception_throw” and press Return. Now, when you run your app in the debugger, any exception will stop there and let you see the exception type.

Where Am I?

You are currently browsing the iPhone category at bunnyhero dev.

i730 ringtones free poly ringtones cell phone ringtones free siemens a50 ringtones free ringtones for lg download free cricket ringtones composer motorola free ringtones real sound ringtones ringtones for samsung composer blackberry 8310 ringtones free blackberry ringtones compose my own ringtones free lost boyz renee ringtones chicago the movie ringtones free real music ringtones download able free ringtones for samsung alltel free ringtones canada sony ericsson ringtones nokia 3210 ringtones composer free ringtones for lg phones free motorola c333 ringtones keypress disney ringtones free i95 nextel ringtones verizon wireless ringtones ringtones for samsung r225 motorola v60 ringtones college ringtones free alltel ringtones free ringtones for nokia phones free ringtones for sprint phones tracfone ringtones free motorola polyphonic ringtones free samsung keypress ringtones free us cellular ringtones keypress motorola c350 ringtones ringtones iphone ringtones for cell phones ringtones for nokia ringtones for blackberry ringtones on iphone t mobile sidekick ringtones free ringtones cingular cellphone ringtones free cellphone ringtones video game ringtones sprintpcs ringtones videogame ringtones ringtones for nokia 3390 free ringtones for sprintpcs ringtones for nokia phones cellular ringtones free sprintpcs ringtones ringtones and picture messages nokia cellphone ringtones cellular phone ringtones ringtones for cellphone ringtones for mobile phones free ringtones sprintpcs ringtones for sprintpcs ringtones for verizon wireless lg 5250 ringtones ringtones sprintpcs nokia polyphonic ringtones free ringtones for cell phones free cellular ringtones ringtones for motorola phones free verizon wireless ringtones free ringtones for nokia cell phones free ringtone shut up ringtone ringtone maker ghost ringtone free ringtone downloads free ringtone websites ringtone free mobile ringtone downloads airtel ringtone free polyphonic ringtone sanyo ringtone download free us cellular ringtone downloads mosquito ringtone free cingular ringtone make ringtone free ringtone maker ringtone software notre dame ringtone free ringtone composer inxs what you need ringtone where can i find free ringtone 24 ringtone polyphonic ringtone nokia ringtone iden ringtone loader cellphone ringtone mp3 to ringtone where can i get a free nokia ringtone free nokia ringtone free polyphonic ringtone composer motorola ringtone randy orton ringtone crank ringtone tv ringtone ringtone composer nascar ringtone boomer sooner ringtone free ringtone creator the godfather ringtone hawaii 5 0 ringtone mp3 ringtone flint phone ringtone phone prepaid wireless ringtone nokia old fashioned telephone ringtone compose a ringtone on my phone free ringtone converter free ringtone download what you need ringtone motorola ringtone composer nextel ringtone converters ringtone ripper free 24 ringtone free ringtone downloads nokia 50 cent ringtone free ringtone for sendo free mp3 to ringtone converter mosquito ringtone download chris tucker ringtone free rogers ringtone ringtone farm cingular free prepaid ringtone polyphonic ringtone composer download free cingular wireless ringtone free mobile phone ringtone samsung wicked game ringtone for sprint ya callate ringtone download ringtone malay caller ringtone free audiovox ringtone downloads ringtone creator imperial march ringtone free nokia ringtone composers polyphonic ringtone converter togo tmobile ringtone motorola c115 download ringtone download free motorola phone ringtone download free ringtone free nokia tracfone ringtone ringtone notes jekyll ringtone hawaii 50 ringtone back to the hotel ringtone free music ringtone samsung ringtone composer samsung ringtone cingular 8125 ringtone verizon free ringtone wireless nextel ringtone motorola iden ringtone programs nextel nextel 1860 ringtone software sano ringtone download free ringtone rippers ringtone free yea alabama ringtone scotty doesnt know ringtone acid ringtone tutorial eurotrip ringtone free flo rida low ringtone ringtone format smartphone ringtone free tmobile ringtone downloads uk 24 ctu ringtone free cingular siemens a23330 ringtone mp3 to ringtone converter tmobile ringtone motorola 120c keypress ringtone nokia 3310 ringtone composer free cellular ringtone ringtone to razr harry potter ringtone motorola v60 ringtone composer notes 2100 free nokia ringtone alltel free real ringtone cell motorola phone ringtone v60i free lg ringtone verizon vx3300 ghostbusters ringtone listen to crazy frog ringtone message in a bottle ringtone the good the bad and the ugly ringtone kyocera ringtone downloads crank movie ringtone iphone ringtone torrent ctu ringtone ringtone adults cant hear codes for ringtone composer free sms ringtone tarzan ringtone ringtone maker freeware cell phone make your own ringtone ringtone mp3 free scrat for ringtone cellular one ringtone and wallpaper free virgin mobile ringtone free motorola ringtone codes ringtone jukebox mp3 ringtone maker free duffle bag boy ringtone where can i compose my own ringtone the lone gunmen ringtone samsung sghe105 free sms ringtone silent ringtone nextel ringtone creator free trial free mp3 ringtone centro ringtone nokia 6560 download free ringtone blackberry ringtone urban dream ringtone free ringtone uploads composer free nokia phone ringtone free ringtone for motorola composer ringtone notes free nokia ringtone converter 24 ctu ringtone nokia mobile ringtone ringtone composer notes how do i make a ringtone from a song 8100 free phone ringtone sanyo sprint convert mp3 to ringtone stayin alive ringtone place to get free ringtone buy ringtone ringtone senders download nextel ringtone software motorola polyphonic ringtone t720 usa oompa loompa ringtone free cingular ringtone usa go cubs go ringtone free nextel ringtone software i730 free tv ringtone downloads convert ringtone ringtone websites create your own ringtone ringtone rolling stone dream theater ringtone free motorola ringtone downloads totally free ringtone ringtone sites your phone cell ringtone 633 squadron ringtone free ringtone cell phone free ringtone for motorola a630 cellular free phone prepaid ringtone ringtone converter create a polyphonic ringtone bbc cricket ringtone nokia 3100 ringtone download euro ringtone trip steam train whistle ringtone free motorola composer ringtone free ringtone keypress composer ringtone converter software for nextel 3588i free ringtone sprint free ringtone for verizon cell phone crazy frog ringtone composer motorola ringtone download mp3 nextel ringtone ringtones ringtones free ringtones for free ringtones for iphone ringtones download ringtone downloads free nokia 3390 ringtone nokia 3390 ringtone composer nokia 3390 ringtone 50 cent in da club ringtone in da club ringtone coding workshop ringtone converter free ringtones download free ringtones xmas ringtones free mobile phone ringtones motorola ringtones free free nokia ringtones free cell phones ringtones download free ringtones to cellphone free kyocera 2235 ringtones free sprint ringtones cricket ringtones cheap nokia ringtones free logos ringtones free ringtones samsung nokia ringtones free verizon ringtones verizon ringtones polyphonic ringtones online ringtones for a cricket carrier polyphonic ringtones mp3 ringtones ringtones composer free sms ringtones motorola ringtones free no catch ringtones real music ringtones ringtones for a samsung polyphonic ringtones free cricket free ringtones tv ringtones free real ringtones free mp3 ringtones cheap polyphonic ringtones free ringtones for my phone polyphonic ringtones for motorola free download nokia ringtones free sanyo ringtones free cricket ringtones free polyphonic ringtones cheap polyphonic ringtones for motorola nextel ringtones free samsung ringtones free download able polyphonic ringtones free composer ringtones lg ringtones nokia 3360 free ringtones spooky ringtones cheap ringtones logos voice ringtones kyocera ringtones tv theme ringtones composer ringtones for motorola tv movie ringtones keypress ringtones ringtones for us cellular phones free downloadable nokia ringtones downloadable free ringtones for samsung free ringtones for nokia 5165 3310 ringtones composer free ringtones 4 samsung free ringtones for kyocera phones samsung polyphonic ringtones panasonic polyphonic ringtones cheap polyphonic ringtones by sms free polyphonic ringtones samsung virgin mobile ringtones for free totally free ringtones free siemens ringtones compose motorola ringtones free mobile ringtones motorola v60 free ringtones turkey ringtones samsung ringtones high school musical ringtones kyocera free ringtones c350 motorola ringtones for free polyphonic ringtones for a motorola c350 free motorola ringtones free polyphonic ringtones order free downloadable polyphonic ringtones free nextel ringtones free ringtones verizon make your own ringtones real ringtones nokia 3390 composer ringtones kyocera 6035 free ringtones iphone ringtones ringtones for virgin mobile users free ringtones sent to cellphone in usa blackberry ringtones free nokia 3390 ringtones free ericsson ringtones cheap ringtones by text talking ringtones downloadable free ringtones ringtones for samsung a300 panasonic melody composer ringtones free actual song ringtones ringtones for samsung phones free voice ringtones ringtones for motorola cell phones free polyphonic ringtones for usa free ringtones via sms download samsung ringtones free cingular ringtones usa the police ringtones hilarious ringtones send real music ringtones polyphonic ringtones for samsung a300 free hip hop ringtones free polyphonic ringtones usa free composer ringtones for nokia free kyocera ringtones polyphonic ringtones tv themes free christmas ringtones alltel ringtones kyocera 2255 ringtones 3310 nokia ringtones composers free tracfone ringtones free samsung t100 ringtones kyocera 2235 ringtones cingular ringtones motorola 120c free ringtones free downloadable ringtones for cricket download free polyphonic ringtones free siemens mobile ringtones samsung sch a310 ringtones cheap ringtones motorola ringtones free cingular turkey gobble ringtones free composer ringtones nelly att ringtones ringtones for nextel free virgin mobile ringtones free ringtones for cingular samsung a460 ringtones music ringtones send free ringtones mobile phone ringtones soap ringtones cricket communications ringtones free mp3 reggae ringtones cingular wireless ringtones ringtones mp3 free music ringtones nick manning ringtones download free ringtones to cellophane christmas ringtones download ringtones hi fi ringtones free sms logos ringtones free strange ringtones ringtones free kyocera samsung free cingular ringtones samsung ringtones download