Skip to content

Instantly share code, notes, and snippets.

View hatfinch's full-sized avatar

Hamish Allan hatfinch

View GitHub Profile
@hatfinch
hatfinch / UIDocumentSubclass.m
Created January 20, 2012 17:43
// Workaround for buggy UIDocument methods
@implementation UIDocumentSubclass
{
UIDocumentState myDocumentState;
}
- (void)openWithCompletionHandler:(void (^)(BOOL success))completionHandler
{
dispatch_queue_t originalQueue = dispatch_get_current_queue();
NSFileCoordinator *coordinator = [[NSFileCoordinator alloc] initWithFilePresenter:self];
@hatfinch
hatfinch / CGAffineTransformFromRectToRect.m
Created August 17, 2011 09:54
CGAffineTransformFromRectToRect (not working)
CGAffineTransform CGAffineTransformFromRectToRect(CGRect fromRect, CGRect toRect)
{
CGSize scale = CGSizeMake(toRect.size.width / fromRect.size.width, toRect.size.height / fromRect.size.height);
CGRect scaledFromRect = CGRectMake(fromRect.origin.x * scale.width, fromRect.origin.y * scale.height,
fromRect.size.width * scale.width, fromRect.size.height * scale.height);
CGSize translation = CGSizeMake(fromRect.origin.x - scaledFromRect.origin.x, fromRect.origin.y - scaledFromRect.origin.y);
return CGAffineTransformMake(scale.width, 0.0, 0.0, scale.height, translation.width, translation.height);
}
@hatfinch
hatfinch / TestView.m
Created January 3, 2012 01:01
Empirical determination of TouchUpInside area
//
// TestView.m
// ButtonHitTest
//
// Created by Hamish Allan on 03/01/2012.
//
#import "TestView.h"
@implementation TestView
- (void)performLayout
{
[super performLayout];
myScrubView.frame = self.bounds;
BOOL reload = NO;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait)
{
@hatfinch
hatfinch / OLVIconViewCell.h
Created July 26, 2011 17:40
Autogenerated ivars not retained by ARC
@interface OLVIconViewCell : UIView
@property(nonatomic, readonly) NSString *reuseIdentifier;
@property(nonatomic, readonly) UILabel *textLabel;
@property(nonatomic, readonly) UILabel *detailTextLabel;
@property(nonatomic, readonly) UIImageView *imageView;
- (id)initWithReuseIdentifier:(NSString *)identifier;
- (void)prepareForReuse;
#import <Foundation/Foundation.h>
@interface OTActivityIndicatorView : UIActivityIndicatorView
{
}
@end
from: Pam Giddy, Director POWER2010 <office@power2010.org.uk>
reply-to: office@power2010.org.uk
to: hamish@gmail.com
date: Thu, Feb 18, 2010 at 3:23 PM
subject: Fwd: Time for a strong finish
Dear Friend,
I've just received this email from Mark Ross - POWER2010's Head of Campaigns - and I wanted to share it with you.