Skip to content

Instantly share code, notes, and snippets.

View JigsChanchiya's full-sized avatar

Jignesh Chanchiya JigsChanchiya

View GitHub Profile
@JigsChanchiya
JigsChanchiya / customswipetodelete.mm
Created October 16, 2013 05:08
In uitableview performs the swipe action with custom delete button.
/*
This method will be called when user performs the swipe action
Just Place this in your CustomCell
*/
- (void)willTransitionToState:(UITableViewCellStateMask)state
@JigsChanchiya
JigsChanchiya / Keybord+Notification+iOS.mm
Created October 15, 2013 12:08
Keybord notifications in OS
/*
UIKeyboardWillShowNotification
UIKeyboardDidShowNotification
UIKeyboardWillHideNotification
UIKeyboardDidHideNotification
*/
@JigsChanchiya
JigsChanchiya / UIImageView+Download.mm
Created October 11, 2013 04:51
Download image from url async
#import "UIImageView+Download.h"
@implementation UIImageView (Download)
-(void)downloadFromURL:(NSString *)url withPlaceholder:(UIImage *)placehold
{
if (placehold) {
[self setImage:placehold];
}
if (url) {
@JigsChanchiya
JigsChanchiya / macro.mm
Last active January 13, 2016 05:28
macro
typedef enum {
NotiContact=0,
NotiChatNoti,
NotiMyNoti
} NotiSelect;
//Colors
#define COLOR(r,g,b) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:1]
#define COLOR_BACKGROUND [UIColor colorWithRed:(230.0/255) green:(224.0/255) blue:(202.0/255) alpha:1.0]
@JigsChanchiya
JigsChanchiya / suffixDate.mm
Last active January 28, 2016 02:52
date formatting with suffix
-(NSString *)StringFromDate:(NSDate *)DateLocal{
NSDateFormatter *prefixDateFormatter = [[[NSDateFormatter alloc] init] autorelease];
[prefixDateFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[prefixDateFormatter setDateFormat:@"MMMM d., yyyy"];//June 13th, 2013
NSString * prefixDateString = [prefixDateFormatter stringFromDate:DateLocal];
NSDateFormatter *monthDayFormatter = [[[NSDateFormatter alloc] init] autorelease];
[monthDayFormatter setFormatterBehavior:NSDateFormatterBehavior10_4];
[monthDayFormatter setDateFormat:@"d"];
int date_day = [[monthDayFormatter stringFromDate:DateLocal] intValue];
@JigsChanchiya
JigsChanchiya / Region+Annotations+MapView.mm
Created June 22, 2013 13:23
Get map view region based on all annotation pin for screen fit size zoom.
-(MKCoordinateRegion) regionForAnnotations:(NSMutableArray *)annotations
{
double minLat=90.0f, maxLat=-90.0f;
double minLon=180.0f, maxLon=-180.0f;
for (id<MKAnnotation> mka in annotations) {
if ( mka.coordinate.latitude < minLat ) minLat = mka.coordinate.latitude;
if ( mka.coordinate.latitude > maxLat ) maxLat = mka.coordinate.latitude;
if ( mka.coordinate.longitude < minLon ) minLon = mka.coordinate.longitude;
if ( mka.coordinate.longitude > maxLon ) maxLon = mka.coordinate.longitude;
@JigsChanchiya
JigsChanchiya / DBHelper+CoreData.mm
Created June 4, 2013 05:50
Coredata helper methods in objective-c
#pragma mark -
#pragma mark - Creating Object
-(id)createObjectForEntity:(NSString *)entityName
{
if (entityName!=nil || [entityName isEqualToString:@""])
{
return [NSEntityDescription
insertNewObjectForEntityForName:entityName
inManagedObjectContext:appDelegate.managedObjectContext];
@JigsChanchiya
JigsChanchiya / Scale+Rotate+UIImage.mm
Last active December 17, 2015 22:39
Scale and Rotate UIImage
# pragma mark -
# pragma mark - Scale and Rotate according to Orientation
- (UIImage *)scaleAndRotateImage:(UIImage *)image
{
int kMaxResolution = 450; // Or whatever
CGImageRef imgRef = image.CGImage;
CGFloat width = CGImageGetWidth(imgRef);