Skip to content

Instantly share code, notes, and snippets.

View mjjimenez's full-sized avatar

Mark Jimenez mjjimenez

View GitHub Profile
@mjjimenez
mjjimenez / 0_reuse_code.js
Created October 3, 2013 11:54
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@mjjimenez
mjjimenez / StoryboardController
Created October 17, 2013 07:29
Get the first view controller of a storyboard
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"HelpStoryboard" bundle:nil];
UIViewController* initialHelpView = [storyboard instantiateInitialViewController];
@mjjimenez
mjjimenez / .gitattributes
Created October 18, 2013 03:35
Set pbxproj as binary and merge rule as union
*.pbxproj binary merge=union
@mjjimenez
mjjimenez / add_activity_indicator
Created October 18, 2013 06:07
Add an activity indicator as a subview
//Create and add the Activity Indicator to splashView
UIActivityIndicatorView *activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];
activityIndicator.alpha = 1.0;
activityIndicator.center = CGPointMake(160, 360);
activityIndicator.hidesWhenStopped = NO;
[splashView addSubview:activityIndicator];
[activityIndicator startAnimating];
@mjjimenez
mjjimenez / adjust_view_frame
Created October 18, 2013 06:28
Adjust offset of view when keyboard hides a textfield
- (void)viewWillAppear:(BOOL)animated
{
// register for keyboard notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
@mjjimenez
mjjimenez / add_refresh_control
Created October 18, 2013 15:25
Add UIRefreshControl to UICollectionView
UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init];
refreshControl.tintColor = [UIColor grayColor];
[refreshControl addTarget:self action:@selector(refershControlAction) forControlEvents:UIControlEventValueChanged];
[self.collectionView addSubview:refreshControl];
self.collectionView.alwaysBounceVertical = YES;
@mjjimenez
mjjimenez / update_tableview_cell
Created October 23, 2013 06:00
Adjust tableview cell properties without reloading contents
[self.tableView beginUpdates];
[self.tableView endUpdates];
@mjjimenez
mjjimenez / clear_textfield_button
Created October 23, 2013 11:16
Show "clear textfield" button on textfield
myUITextField.clearButtonMode = UITextFieldViewModeWhileEditing;
@mjjimenez
mjjimenez / datepicker_with_toolbar.m
Created October 24, 2013 06:35
Create date picker with accessory view and attach it to a uitextfield
- (void)viewDidLoad
{
UIDatePicker *datePicker = [[UIDatePicker alloc] init];
datePicker.datePickerMode = UIDatePickerModeDate;
UIToolbar *toolbar =[[UIToolbar alloc]initWithFrame:CGRectMake(0,0, self.view.frame.size.width,44)];
toolbar.barStyle =UIBarStyleDefault;
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
@mjjimenez
mjjimenez / remove_cursor.m
Created October 24, 2013 06:53
Remove cursor from UITextField
//Subclass UITextfield and Override the - (CGRect)caretRectForPosition:(UITextPosition *)position //method and return CGRectZero.
- (CGRect)caretRectForPosition:(UITextPosition *)position {
return CGRectZero;
}