Wednesday, April 20, 2011

How to Change UIView Size in Interface Builder

When you create a new UIView XIB in Interface Builder, it is by default full-screen. Width and height cannot be changed, they are dimmed out. What to do?

Switch to Simulated Metrics and change "Status Bar" from default (gray) to None. Now you can edit the size!

First time this was difficult to discover, second time I kind of recalled what to do and now it's all so plain obvious :)

Easy Way to Debug UIView Hierarchy

Do you want to see complete view hierarchy for debugging purposes? There is an easy way to do it, provided by Apple - totally unofficially!

Actually official documentation says it's undocumented and not supported. No problem with that. Very kind of Apple, good developer service!

Monday, April 18, 2011

Operation failed with underlying error 4294956467

Thanx Xcode, that was very informative. I'll fix it right away! Oh wait, what was that...
Failed to launch simulator: Operation failed with underlying error 4294956467.

Friday, April 15, 2011

No New Fonts in iOS 4.3.2 Either

While I still remember... Yes, I checked iOS 4.3.2 update. There are no new fonts, when compared to iPhone or iPad running iOS 4.3 or 4.3.1. Don't have iPad2, but I doubt there's any new fonts in that device alone.

Sometimes no news is the news.

Previously released iOS 4.3 has new Noteworthy font and there is also a complete list of iOS 4.2.1 fonts. I do have locally more complete table of fonts, should make it public.

Got a new feature for my fonts application: autocheck whether there are any new fonts. Invest a day worth of development to save 15 minutes of boring manual work!

Initializer Element Is Not Constant


This code might look valid to less experienced iOS developers, but it does give a compiler error "initializer element is not constant":

static NSArray *playState = [NSArray arrayWithObjects:
    @"MPMoviePlaybackStateStopped",
    @"MPMoviePlaybackStatePlaying",
    @"MPMoviePlaybackStatePaused",
    @"MPMoviePlaybackStateInterrupted",
    @"MPMoviePlaybackStateSeekingForward",
    @"MPMoviePlaybackStateSeekingBackward",
    nil];

Wednesday, April 13, 2011

Better Debug for CGRect, CGPoint and CGSize

Can't remember how many times I've wanted to debug what is the size of a frame. Can't remember how many times I've written x and y coordinates, followed by width and height, to console log.

All wasted time and effort, while I could have been doing something more productive! Live and learn: just found out that iOS SDK contains helper routines for that task:

Monday, April 11, 2011

Easy Way to Create Settings View

Most applications need settings or at least a way to display version number. In theory it's very simple: just show a short list with a few hardcoded rows. It could be difficult, but since "settings" is such a common use case, Apple iOS SDK offers special support. It's not quite perfect, so let's check the possibilities.

Friday, April 8, 2011

Autoreleased with No Pool in Place - Just Leaking

When you perform an operation in another thread, place EVERYTHING inside your thread specific autorelease pool. That includes writing debug messages in log as well as sending notifications. Otherwise you will leak memory.

Thursday, April 7, 2011

How to Reset MPMoviePlayer Timeline

When you stream a video (HTTP Live Streaming) over network till finish, the timeline might show there's still a few seconds missing. The problem is that the initial video duration is an estimation, not the exact video length.

There is a system callback, which is called when real video duration is known:

Wednesday, April 6, 2011

MPMoviePlayer Tips

Trying to make MPMoviePlayer do "things" it doesn't really want to. Finding lots of tips, saving here as reference. Yes, it was a long day. Too many tips to be remembered tomorrow.