Skip to content

Instantly share code, notes, and snippets.

View timd's full-sized avatar
💭
Typing all the right things, not necessarily in the right order

Tim Duckett timd

💭
Typing all the right things, not necessarily in the right order
View GitHub Profile
@timd
timd / draggableUicvHack
Created July 16, 2014 15:27
A draggable UICollectionViewCell hack
(void)handlePan:(UIPanGestureRecognizer *)panRecognizer {
CGPoint locationPoint = [panRecognizer locationInView:self.collectionView];
if (panRecognizer.state == UIGestureRecognizerStateBegan) {
NSIndexPath indexPathOfMovingCell = [self.collectionView indexPathForItemAtPoint:locationPoint];
UICollectionViewCell *cell = [self.collectionView cellForItemAtIndexPath:indexPathOfMovingCell];
UIGraphicsBeginImageContext(cell.bounds.size);
@timd
timd / keybase.md
Last active August 29, 2015 14:18

Keybase proof

I hereby claim:

  • I am timd on github.
  • I am timduckett (https://keybase.io/timduckett) on keybase.
  • I have a public key whose fingerprint is E2F8 8A13 E453 B507 F15D EF4B D8D5 3D9C 4C82 37DF

To claim this, I am signing this object:

@timd
timd / gist:1226528
Created September 19, 2011 13:47
Extended error dump for Core Data errors
if(![managedObjectContext save:&error]) {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
if(detailedErrors != nil && [detailedErrors count] > 0) {
for(NSError* detailedError in detailedErrors) {
NSLog(@" DetailedError: %@", [detailedError userInfo]);
}
}
else {
NSLog(@" %@", [error userInfo]);
@timd
timd / gist:1835386
Created February 15, 2012 12:31
didSwipeLeftInCell:
-(IBAction)didSwipeLeftInCell:(id)sender {
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView animateWithDuration:1.0 animations:^{
[_topView setFrame:CGRectMake(-10, 0, 320, 80)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 animations:^{
[_topView setFrame:CGRectMake(0, 0, 320, 80)];
}];
}];
}
@timd
timd / didSwipeLeftInCell.m
Created February 15, 2012 12:39
didSwipeLeftInCell:
-(IBAction)didSwipeLeftInCell:(id)sender {
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView animateWithDuration:1.0 animations:^{
[_topView setFrame:CGRectMake(-10, 0, 320, 80)];
} completion:^(BOOL finished) {
[UIView animateWithDuration:0.15 animations:^{
[_topView setFrame:CGRectMake(0, 0, 320, 80)];
}];
}];
}
@timd
timd / swipeCell.m
Created February 15, 2012 12:41
initWithStyle:reuseidentifier:
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
// Create the top view
_topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, self.contentView.frame.size.width, 80)];
[_topView setBackgroundColor:[UIColor whiteColor]];
@timd
timd / scrollViewDidEndDragging.m
Created February 16, 2012 10:02
scrollViewDidEndDragging:willDecelerate:
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
CGFloat contentOffsetY = scrollView.contentOffset.y;
if (contentOffsetY < -60.0) {
[self displayActivitySpinner];
}
}
@timd
timd / gist:2317906
Created April 6, 2012 07:24
Simulator-safe method for using the hardware camera on iOS Simulators
-(void)takeSimulatorSafePhotoWithPopoverFrame:(GCRect)popoverFrame {
// Prerequisites:
//
// Class requires two properties to be defined:
//
// @property (nonatomic, strong) UIImagePickerController *imagePicker;
// @property (nonatomic) BOOL usingPopover;
// Load the imagePicker
@timd
timd / .gitignore
Created August 2, 2012 07:34 — forked from Abizern/.gitignore
Global git ignore file
# Mac OS X
*.DS_Store
# Xcode
*.pbxuser
*.mode1v3
*.mode2v3
*.perspectivev3
*.xcuserstate
project.xcworkspace/
@timd
timd / ios-font-list
Created August 3, 2012 10:17
List of onboard iOS fonts in iOS5.1 / Xcode 4.4
Thonburi
"Thonburi-Bold",
Thonburi
Snell Roundhand
"SnellRoundhand-Bold",
"SnellRoundhand-Black",
SnellRoundhand
Academy Engraved LET