Skip to content

Instantly share code, notes, and snippets.

Avatar

Hamish Allan hatfinch

View GitHub Profile
@hatfinch
hatfinch / UIDocumentSubclass.m
Created Jan 20, 2012
// Workaround for buggy UIDocument methods
View UIDocumentSubclass.m
@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 Aug 17, 2011
CGAffineTransformFromRectToRect (not working)
View CGAffineTransformFromRectToRect.m
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 Jan 3, 2012
Empirical determination of TouchUpInside area
View TestView.m
//
// TestView.m
// ButtonHitTest
//
// Created by Hamish Allan on 03/01/2012.
//
#import "TestView.h"
@implementation TestView
View gist:1385399
- (void)performLayout
{
[super performLayout];
myScrubView.frame = self.bounds;
BOOL reload = NO;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if (orientation == UIInterfaceOrientationPortrait)
{
@hatfinch
hatfinch / OLVIconViewCell.h
Created Jul 26, 2011
Autogenerated ivars not retained by ARC
View OLVIconViewCell.h
@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;
View OTActivityIndicatorView.h
#import <Foundation/Foundation.h>
@interface OTActivityIndicatorView : UIActivityIndicatorView
{
}
@end
View 2010-02-18-15-23.txt
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.