29 December 2008

Update: Hello World iphone

KGelner pointed out that my Hello World iphone edition wasn't very good, looks like he was right. I did try to find an official edition. So I found this link: HelloWorldClassic, but it requires registration to access. And by registration, it's not just "get a login" it's "give us your home address". No thanks. Compare that to Android code, which is freely available without a login. I'm not positive, but I'd bet that the Agreement on the developer.apple.com site says that I can't copy and paste code from their site to my blog. Or risk running afoul of the Apple legal team. Anyway, someone posted this code in discussions.apple.com:

- (void) drawRect:(CGRect) rect {
* [UIColor whiteColor] set;*
* [@"Hello World" drawInRect:CGRectMake(0, 175, 320, 50)*
* withFont:UIFont fontWithName:@"Marker Felt" size:40
lineBreakMode:UILineBreakModeMiddleTruncation*
* alignment:UITextAlignmentCenter]; *
}

That looks much better, and not too far off from the Android version. There's something up with the withFont line in the original version, so that line might be incorrect.

No comments:

Post a Comment