Skip to content

Instantly share code, notes, and snippets.

View jlcampana's full-sized avatar
:octocat:
emu emu emu...

Jose Luis Campaña jlcampana

:octocat:
emu emu emu...
View GitHub Profile
@jlcampana
jlcampana / gist:3313284
Created August 10, 2012 10:38
JSON 2 NSDictionary
- (void)apiRequestDone:(ASIHTTPRequest *)request
{
(...)
[NSJSONSerialization JSONObjectWithData:[request responseData] options: NSJSONReadingMutableContainers error:&error]
@jlcampana
jlcampana / gist:3377536
Created August 17, 2012 09:49
Hacer n pops en un UINavigationController
+(void)navigationController:(UINavigationController *)navigationController PopNumberOfViews:(NSInteger)numberOfViews
{
NSInteger count = [navigationController.viewControllers count];
UIViewController *vc = [navigationController.viewControllers objectAtIndex:(count - (1 + numberOfViews))];
[navigationController popToViewController:vc animated:YES];
}
@jlcampana
jlcampana / gist:3377690
Created August 17, 2012 10:11
Customize Navigation Bar
UINavigationBar *navBar = [[self navigationController] navigationBar];
//If we want a custom logo:
UIImage *backgroundImage = [UIImage imageNamed:@"background_im"];
[navBar setBackgroundImage:backgroundImage forBarMetrics:UIBarMetricsDefault];
self.navigationItem.titleView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"logo_img"]] autorelease];
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;
self.navigationController.navigationItem.backBarButtonItem.tintColor = [UIColor redColor];
self.navigationController.navigationBar.tintColor = [UIColor redColor];
@jlcampana
jlcampana / UIColor+IntegerRGB.m
Created August 21, 2012 10:42
UIColor+IntegerRGB.m
//
// UIColor+IntegerRGB.m
// Shell mPayment
//
// Created by Jose Luis Campaña on 8/21/12.
//
//
#import "UIColor+IntegerRGB.h"
@jlcampana
jlcampana / UIColor+IntegerRGB.h
Created August 21, 2012 10:43
UIColor+IntegerRGB.h
//
// UIColor+IntegerRGB.h
// Shell mPayment
//
// Created by Jose Luis Campaña on 8/21/12.
//
//
#import <UIKit/UIKit.h>
@jlcampana
jlcampana / gist:3433394
Created August 23, 2012 06:30
cellForRowAtIndexPath (iOS5 ver)
- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath
{
static NSString* customCellIdentifier = @"CustomCellIdentifier";
CustomCell* cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:customCellIdentifier];
if (cell == nil)// tableview not associated (registered) with nib file.
{
UINib* customCellNib = [UINib nibWithNibName:@"CustomCell" bundle:nil]; // Register this nib file with cell identifier.
[tableView registerNib: customCellNib forCellReuseIdentifier:customCellIdentifier];
}
@jlcampana
jlcampana / gist:3433452
Created August 23, 2012 06:35
Formula to find the width of UILabel with the text length
Formula to find the width of UILabel with the text length
#define MY_LABEL_FONT_SIZE 18
#define MY_LABEL_TEXT_WIDTH_MULTIPLIER(MY_LABEL_FONT_SIZE/2 + 1)
For example if we have a String of length 8 characters then we can find the width of the UILabel which can fit the text as :
8* MY_LABEL_TEXT_WIDTH_MULTIPLIER
and setting the Font Size of the UILabel text as MY_LABEL_FONT_SIZE
@jlcampana
jlcampana / gist:3446424
Created August 24, 2012 06:14
Grados a radianes
static inline double radians (double degrees) {return degrees * M_PI/180;}
@jlcampana
jlcampana / UIImage+Extensions.m
Created August 24, 2012 06:15
UIImage+Extensions.m
//
// UIImage-Extensions.m
//
// Created by Hardy Macia on 7/1/09.
// Copyright 2009 Catamount Software. All rights reserved.
//
#import "UIImage-Extensions.h"
CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
@jlcampana
jlcampana / UIImage+Extensions.h
Created August 24, 2012 06:16
UIImage+Extensions.h
//
// UIImage-Extensions.h
//
// Created by Hardy Macia on 7/1/09.
// Copyright 2009 Catamount Software. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface UIImage (CS_Extensions)
- (UIImage *)imageAtRect:(CGRect)rect;