Skip to content

Instantly share code, notes, and snippets.

View sebastienwindal's full-sized avatar

Sebastien Windal sebastienwindal

View GitHub Profile
-(void) action:(UIButton *)sender
{
CGRect buttonFrame = [sender convertRect:sender.bounds toView:self.tableView];
NSIndexPath *indexPath = [self.tableView indexPathForRowAtPoint:buttonFrame.origin];
...
}
@sebastienwindal
sebastienwindal / static grouped cell background color
Created February 25, 2014 18:45
static grouped cell background color
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
{
cell.backgroundColor = [UIColor clearColor];
}
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"%@", fontName);
}
}
@sebastienwindal
sebastienwindal / keyboard handling in iOS
Last active August 29, 2015 14:00
Make a whole view scroll up to make the control appear when keyboard shows up. self.rootScrollView is a scrollview that stretches in the whole screen.
- (void)observeKeyboard
{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillChangeFrameNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}
- (void)stopObservingKeyboard
{
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillChangeFrameNotification object:nil];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillHideNotification object:nil];
// .h file
@interface LessonManager : NSObject
@property (strong, nonatomic) NSString * imageTitle;
+ (instancetype) sharedInstance;
@end
/*
File: UIImage+ImageEffects.h
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
/*
File: UIImage+ImageEffects.m
Abstract: This is a category of UIImage that adds methods to apply blur and tint effects to an image. This is the code you’ll want to look out to find out how to use vImage to efficiently calculate a blur.
Version: 1.0
Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple
Inc. ("Apple") in consideration of your agreement to the following
terms, and your use, installation, modification or redistribution of
this Apple software constitutes acceptance of these terms. If you do
not agree with these terms, please do not use, install, modify or
@sebastienwindal
sebastienwindal / gist:0f2de5c4504ccd4473d5
Last active August 29, 2015 14:17
animate auto-layout
self.myConstraint.constant = 1234;
[UIView animateWithDuration:0.3 animations:^{
[self.someview layoutIfNeeded];
}];
@sebastienwindal
sebastienwindal / gist:5d747672af966d4b6d83
Last active August 29, 2015 14:20
Core Data Sample
// delete all placeholder meal logs older than a certain date
NSPredicate *oldPlaceholderPredicate = [NSPredicate predicateWithFormat:@"(isPlaceholderMealLog = TRUE) AND (eatenOn < %@)", twoDaysAgoAtMidnight];
[MealLogManaged MR_deleteAllMatchingPredicate:oldPlaceholderPredicate inContext:context];
YapDatabaseViewGroupingWithObjectBlock groupingBlock = ^NSString *(NSString *collection, NSString *key, id object) {
if (![object isKindOfClass:[MealLogRemote class]]) {
return nil;
}
return "all"; // we only need one section/group in this case
};
YapDatabaseViewSortingWithObjectBlock sortingBlock = ^NSComparisonResult (NSString *group, NSString *collection1, NSString *key1, MealLogRemote *obj1,
NSString *collection2, NSString *key2, MealLogRemote *obj2){
// we don't need sorting but this using a sorting for a view is mandatory, lets sort it by date