Skip to content

Instantly share code, notes, and snippets.

View jeksys's full-sized avatar

Eugene Yagrushkin jeksys

View GitHub Profile
@jeksys
jeksys / gist:953396
Created May 3, 2011 14:11
GestureRecognizer
UILongPressGestureRecognizer *recognizer;
recognizer = [[[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPress:)] autorelease];
[self.view addGestureRecognizer: recognizer];
- (void)handleLongPress:(UILongPressGestureRecognizer *)recognizer
+ (BOOL)isRunningOniPad
{
static BOOL hasCheckediPadStatus = NO;
static BOOL isRunningOniPad = NO;
if (!hasCheckediPadStatus)
{
if ([[UIDevice currentDevice] respondsToSelector:@selector(userInterfaceIdiom)])
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
@jeksys
jeksys / gist:953410
Created May 3, 2011 14:22
ANIMATION BLOCK
[UIView animateWithDuration:HIDE_CONTROLS_ANIMATION
animations:^{
// and other controls
self.navigationController.navigationBar.hidden = ControlsHidden;
self.tabbar.hidden = ControlsHidden;
}
completion:^(BOOL finished){
@jeksys
jeksys / EditableViewCell.h
Created May 4, 2011 20:19
EditableViewCell
//
// EditableViewCell.h
// Editable UITableViewCell with a UITextField as an edit tool
// Created by Eugene Yagrushkin on 11-05-04.
// Copyright 2011 Eugene Yagrushkin All rights reserved.
//
#import <UIKit/UIKit.h>
@jeksys
jeksys / gist:957049
Created May 5, 2011 13:43
imageScaledToSize
@interface UIImage (TPAdditions)
- (UIImage*)imageScaledToSize:(CGSize)size;
@end
@implementation UIImage (TPAdditions)
- (UIImage*)imageScaledToSize:(CGSize)size {
UIGraphicsBeginImageContext(size);
[self drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
@jeksys
jeksys / gist:963263
Created May 9, 2011 19:58
Delegate template
@protocol SomeClassDelegate <NSObject>
- (void) SomeClassSelector:(ParamType*)param;
@end
@interface SomeClass : UIViewController {
id <SomeClassDelegate> delegate;
@jeksys
jeksys / gist:964506
Created May 10, 2011 13:50
List Of Fonts in the system
NSArray *names = [UIFont familyNames];
for (NSString *fontName in names) {
NSLog(@"%@:", fontName);
NSArray *fontnames = [UIFont fontNamesForFamilyName:fontName];
for (NSString *fontNameinFamily in fontnames) {
NSLog(@"-->%@", fontNameinFamily);
}
}
@jeksys
jeksys / gist:1049376
Created June 27, 2011 17:57
Full screen
[self setWantsFullScreenLayout:YES];
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackTranslucent animated:YES];
self.navigationController.navigationBar.translucent = YES;
self.navigationController.navigationBar.backgroundColor = [UIColor clearColor];
self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
[[UIApplication sharedApplication] setStatusBarHidden:ControlsHidden];
@jeksys
jeksys / gist:1049759
Created June 27, 2011 20:33
drawRect
- (void)drawRect:(CGRect)rect
{
CGContextRef context = UIGraphicsGetCurrentContext(); // get current context
// CGFloat object_size = sizeStatus/2;
// CGFloat sx, sy, fsize = object_size;
// sx = rect.size.width - fsize;
// sy = fsize;
// CGContextMoveToPoint(context, sx, sy);
@jeksys
jeksys / gist:1065330
Created July 5, 2011 17:22
Vibration
AudioToolbox.framework
#import <AudioToolbox/AudioServices.h>
Now use this line of code everytime you want to make the phone vibrate:
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);