Notes from Bordertown Labs with posts regarding software development for the iPhone, Ruby on Rails, tips and code.
» Contact with inquiries.
Visualize your geodata in augmented reality with 3DAR by Spot Metrix. |
(via How to Check-In Using the Facebook iOS SDK and Graph API | Tyler White Design)
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
NSURL *url = [NSURL URLWithString:@"http://bit.ly/nUX01h"];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[NSURLConnection sendAsynchronousRequest:req
queue:[NSOperationQueue currentQueue]
completionHandler:
^(NSURLResponse *res, NSData *data, NSError *err) {
// Convert the data to a UIImage
UIImage *image = [UIImage imageWithData:data];
// Scale the image
UIImage *thumbImage = nil;
CGSize newSize = CGSizeMake(90, (90 / image.size.width) * image.size.height);
UIGraphicsBeginImageContext(newSize);
[image drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
thumbImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
dispatch_async(dispatch_get_main_queue(), ^{
self.imageView.image = thumbImage;
});
}];
});
The iPhone Development Wiki has a very nice listing of private animations which are available but not necessarily acceptable by Apple.
Here’s how to show the coveted iris animation.
I recommend setting the duration to INT_MAX and taking a screenshot of the closed iris and then throwing that into a UIImageView to display before the animation begins, then hide the image right after starting the animation.
CATransition *animation = [CATransition animation];
animation.delegate = self;
animation.duration = 0.33;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.type = @"cameraIrisHollowOpen"; // Or cameraIrisHollowClose, cameraIris
[someContainerView.layer addAnimation:animation forKey:nil];
For almost every app we’ve made, I find myself writing “model classes” to store structured data and logic.
This all started when André Pang wrote an amazing model base class called RMModelObject a few years back that is incredibly sophisticated and provides these same great features on the legacy ObjC runtime. RMModelObject was the inspiration for my class, which was much easier to write since ObjC 2.0 does all the heavy lifting.
The sample code provided in this package reflects the state of the code as of WWDC 2010. For the most up to date sample code see the Reference Libraries at http://developer.apple.com.
See http://developer.apple.com/videos/wwdc/2010/ for slides and videos.
The MPMoviePlayerController was changed (since OS 3.2). It now contains a ‘view’ property that you must add to your view hierarchy, don’t forget to set the frame size as well. EDIT: Sorry, that was a bit premature. Here’s how I play movies on the iPhone now.
if ([UIViewController instancesRespondToSelector:@selector(presentMoviePlayerViewControllerAnimated:)])
{
// >= SDK 3.2
MPMoviePlayerViewController *movieVC = // init
...
[someController presentMoviePlayerViewControllerAnimated:movieVC];
}
else
{
// pre SDK 3.2
MPMoviePlayerController *moviePlayer = // init
...
[moviePlayer play];
}
![]()
Asynchronous calls to S3 from the iPhone. Nice.
This works great on the iPhone.
ZipArchive* za = [[ZipArchive alloc] init];
if ([za UnzipOpenFile:@"/Volumes/data/testfolder/Archive.zip"]) {
BOOL ret = [za UnzipFileTo:@"/Volumes/data/testfolder/extract" overWrite:YES];
if (NO == ret) {
}
[za UnzipCloseFile];
}
[za release];
For iPhone swipe gestures.