Skip to content

Instantly share code, notes, and snippets.

View danielgomezrico's full-sized avatar

Daniel Gomez danielgomezrico

View GitHub Profile
@danielgomezrico
danielgomezrico / TabBarViewControllerColor
Created December 11, 2014 15:35
Change selection color for UITabBarViewController
self.tabBar.selectedImageTintColor = UIColor.colorWithHexString(Constants.mainTabBarSelectionColor)
@danielgomezrico
danielgomezrico / UIScrollView+PullToRefresh.m
Last active August 29, 2015 14:11 — forked from kreeger/UIScrollView+PullToRefresh.m
Category to add pull to refresh to any UIScrollView
//
// UIScrollView+PullToRefresh.h
// Created by Ben Kreeger (@kreeger), 2013/01/23.
//
#import <UIKit/UIKit.h>
/** Adds pull to refresh for a UIScrollView (or a UITableView). Abstracts away differences in frameworks between iOS 6
* and iOS 5 (in the case of the latter, `ODRefreshControl` is used.
*/
@danielgomezrico
danielgomezrico / InfiniteScroll
Last active August 29, 2015 14:12
Infinite scroll for UITableView for iOS http://stackoverflow.com/a/10404477/273119
func scrollViewDidScroll(scrollView: UIScrollView) {
let actualPosition = scrollView.contentOffset.y
let contentHeight = scrollView.contentSize.height - tableView.frame.size.height
if actualPosition >= contentHeight {
tableView.reloadData()
}
@danielgomezrico
danielgomezrico / DefaultDrawerSetup
Last active August 29, 2015 14:12
Default Drawer setup for MMDrawerController (https://github.com/mutualmobile/MMDrawerController). Use border gesture recognition for open and full view swipe recognition for close.
let newCenterViewController = storyboard?.instantiateViewControllerWithIdentifier("CenterViewController") as UIViewController
let newLeftViewController = storyboard?.instantiateViewControllerWithIdentifier("LeftViewController") as UIViewController
let newRightViewController = storyboard?.instantiateViewControllerWithIdentifier("RightViewController") as UIViewController
centerViewController = newCenterViewController
leftDrawerViewController = newLeftViewController
rightDrawerViewController = newRightViewController
openDrawerGestureModeMask = MMOpenDrawerGestureMode.BezelPanningCenterView // Just from border
closeDrawerGestureModeMask = MMCloseDrawerGestureMode.All
@danielgomezrico
danielgomezrico / run_xcpretty_tests.sh
Created January 9, 2015 20:44
Run xcpretty over xcodebuild with reports script
#!/bin/bash
#
# Script to run tests and see a beautiful output using xcpretty.
#
# Validations
if ! which xcpretty >/dev/null; then
echo "Please install xcpretty to run this script."
exit 1
fi
@danielgomezrico
danielgomezrico / UISearchBar+EnableEmptySearch.h
Created January 30, 2015 19:00
Enable search button on keyboard with empty value on UISearchBar
#import <UIKit/UIKit.h>
@interface UISearchBar (UISearchBar_EnableEmptySearch)
- (void)enableEmptySearch;
@end
@danielgomezrico
danielgomezrico / NSUserDefaults+Clear
Last active August 29, 2015 14:14
clearAll function for NSUserDefaults
extension NSUserDefaults {
func clearAll() {
let dictionary = self.dictionaryRepresentation()
for (item, value) in dictionary {
let key = item as String
removeObjectForKey(key)
}
@danielgomezrico
danielgomezrico / SendEmail
Last active August 29, 2015 14:15
Send email in iOS 8 with receipt and subject (you can add a body with possible HTML value too)
if MFMailComposeViewController.canSendMail() {
let subject = NSLocalizedString("MoreEmailSubject", comment: "")
// It send the email async and notify its mailComposeDelegate with updates.
// In the case of no internet connection on send, it will say that the status is sended and
// will be sended automatically when the device get internet connection again.
var mailComposeViewController = MFMailComposeViewController()
mailComposeViewController.setToRecipients([GlobalConstants.CEBrokerData.Support.email])
mailComposeViewController.setSubject(subject)
mailComposeViewController.mailComposeDelegate = self
@danielgomezrico
danielgomezrico / AutolayoutTableViewCell
Created March 13, 2015 18:41
Autolayout For UITableView
class SelectableCell: UITableViewCell {
override func awakeFromNib() {
super.awakeFromNib()
if let myconstraints = constraints() as? [NSLayoutConstraint] {
for cellConstraint: NSLayoutConstraint in myconstraints {
removeConstraint(cellConstraint)
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import java.util.List;
/**
* Created by danielgomez22 on 3/14/15.