Wednesday, December 31, 2014

Core Graphics Drawing



1.)Drawing a Line Segment
----------------------------------
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextMoveToPoint(context, 50, 200);
CGContextAddLineToPoint(context,100,100);
CGContextMoveToPoint(context, 50, 200);
CGContextAddLineToPoint(context,200,400);
CGContextStrokePath(context);


2.)Drawing a Filled Circle
--------------------------------
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(contextRef, 255, 0, 255, 0.9);
CGContextSetRGBStrokeColor(contextRef, 255, 0, 0, 0.9);
CGContextFillEllipseInRect(contextRef, CGRectMake(100, 100, 50, 50));


3.)Drawing a Hollow Circle
----------------------------------
CGContextRef contextRef = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(contextRef, 255, 0, 255, 0.9);
CGContextSetRGBStrokeColor(contextRef, 255, 0, 0, 0.9);
CGContextStrokeEllipseInRect(contextRef, CGRectMake(200, 100, 50, 50));


4.)Drawing a circle with boundary
------------------------------------------
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(context, 0, 255, 0, 1);
CGContextFillEllipseInRect(context, CGRectMake(100, 200, 25, 25));
CGContextSetLineWidth(context, 2.0);
CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor);
CGContextStrokeEllipseInRect(context,CGRectMake(100, 200, 25, 25));


5.)Drawing a Hollow Rectangle
---------------------------------------
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 255, 255, 0, 1);
CGContextStrokeRect(ctx, CGRectMake(195, 195, 60, 60));


6.)Drawing a Solid Rectangle
------------------------------------
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBFillColor(ctx, 255, 255, 0, 1);
CGContextFillRect(ctx, CGRectMake(260, 195, 60, 60));


7.)Drawing a Triangle
----------------------------
CGContextRef ctx = UIGraphicsGetCurrentContext();
CGContextSetRGBStrokeColor(ctx, 255, 0, 255, 1);
CGPoint points[6] = { CGPointMake(200, 200), CGPointMake(250, 250),
CGPointMake(250, 250), CGPointMake(100, 250),
CGPointMake(100, 250), CGPointMake(200, 200) };
CGContextStrokeLineSegments(ctx, points, 6);







Tuesday, December 30, 2014

Resize Image using ImageIO.framework


-(UIImage*)resizeImageToMaxSize:(CGFloat)max
{
    CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)[NSURL fileURLWithPath:path], NULL);
    if (!imageSource)
        return nil;

    CFDictionaryRef options = (CFDictionaryRef)[NSDictionary dictionaryWithObjectsAndKeys:
        (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailWithTransform,
        (id)kCFBooleanTrue, (id)kCGImageSourceCreateThumbnailFromImageIfAbsent,
        (id)[NSNumber numberWithFloat:max], (id)kCGImageSourceThumbnailMaxPixelSize,
        nil];
    CGImageRef imgRef = CGImageSourceCreateThumbnailAtIndex(imageSource, 0, options);

    UIImage* scaled = [UIImage imageWithCGImage:imgRef];

    CGImageRelease(imgRef);
    CFRelease(imageSource);

    return scaled;
}

Blocks in UITableViewCell


@interface MyTableViewCell

@property(nonatomic, copy) void (^checkboxHandler)(void);

@end


@implementation MyTableViewCell

- (IBAction)checkboxPressed:(UIButton *)sender {
self.checkboxHandler();
}

@end



@implementation MyTableViewController

- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    MyTableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"cell"
    forIndexPath:indexPath;
    cell.checkboxHandler = ^{
    // Perform the desired work in response to checkbox
    };
    return cell;
}

@end


ImageIO.framework Example

#import <ImageIO/ImageIO.h>

NSURL *imageFileURL = [NSURL fileURLWithPath:...];
CGImageSourceRef imageSource = CGImageSourceCreateWithURL((CFURLRef)imageFileURL, NULL);
if (imageSource == NULL) {
    // Error loading image
    ...
    return;
}

NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                         [NSNumber numberWithBool:NO], (NSString *)kCGImageSourceShouldCache,
                         nil];
CFDictionaryRef imageProperties = CGImageSourceCopyPropertiesAtIndex(imageSource, 0, (CFDictionaryRef)options);
if (imageProperties) {
    NSNumber *width = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelWidth);
    NSNumber *height = (NSNumber *)CFDictionaryGetValue(imageProperties, kCGImagePropertyPixelHeight);
    NSLog(@"Image dimensions: %@ x %@ px", width, height);
    CFRelease(imageProperties);
}
CFRelease(imageSource);

========================================================

CFDictionaryRef exif = CFDictionaryGetValue(imageProperties, kCGImagePropertyExifDictionary);
if (exif) {
  NSString *dateTakenString = (NSString *)CFDictionaryGetValue(exif, kCGImagePropertyExifDateTimeOriginal);
  NSLog(@"Date Taken: %@", dateTakenString);
}

CFDictionaryRef tiff = CFDictionaryGetValue(imageProperties, kCGImagePropertyTIFFDictionary);
if (tiff) {
    NSString *cameraModel = (NSString *)CFDictionaryGetValue(tiff, kCGImagePropertyTIFFModel);
    NSLog(@"Camera Model: %@", cameraModel);
}

CFDictionaryRef gps = CFDictionaryGetValue(imageProperties, kCGImagePropertyGPSDictionary);
if (gps) {
    NSString *latitudeString = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitude);
    NSString *latitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLatitudeRef);
    NSString *longitudeString = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitude);
    NSString *longitudeRef = (NSString *)CFDictionaryGetValue(gps, kCGImagePropertyGPSLongitudeRef);
    NSLog(@"GPS Coordinates: %@ %@ / %@ %@", longitudeString, longitudeRef, latitudeString, latitudeRef);
}


=======================================================

Date Taken: 2011:03:27 11:30:30
Camera Model: Canon EOS 20D
GPS Coordinates: 8.374788 E / 54.89472 N



Wednesday, December 24, 2014

Round two corners of UIView


-(void) setMaskTo:(UIView*)view byRoundingCorners:(UIRectCorner)corners withRadius:(CGFloat)radius;
{
    UIBezierPath* rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(radius, radius)];
    CAShapeLayer* shape = [[CAShapeLayer alloc] init];
    [shape setPath:rounded.CGPath];

    view.layer.mask = shape;
}


[self setMaskTo:view1 byRoundingCorners:UIRectCornerTopLeft|UIRectCornerBottomLeft withRadius:20.0];

CABasicAnimation Examples



UIView *AnimView1=[[UIView alloc] initWithFrame:CGRectMake(30, 50, 50, 50)];
AnimView1.backgroundColor=[UIColor greenColor];
[self.view addSubview:AnimView1];

UIView *AnimView2=[[UIView alloc] initWithFrame:CGRectMake(90, 75, 50, 50)];
AnimView2.backgroundColor=[UIColor orangeColor];
[self.view addSubview:AnimView2];

UIView *AnimView3=[[UIView alloc] initWithFrame:CGRectMake(170, 90, 50, 50)];
AnimView3.backgroundColor=[UIColor yellowColor];
[self.view addSubview:AnimView3];

UIView *AnimView4=[[UIView alloc] initWithFrame:CGRectMake(240, 150, 50, 50)];
AnimView4.backgroundColor=[UIColor blueColor];
[self.view addSubview:AnimView4];

//shrink
CABasicAnimation* shrink = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
shrink.toValue = [NSNumber numberWithDouble:0.5];
shrink.duration = 0.5;
shrink.delegate = self;
shrink.repeatCount=INFINITY;
shrink.autoreverses=YES;
[[AnimView1 layer] addAnimation:shrink forKey:@"shrinkAnim"];

//moving
CABasicAnimation *Animation1;
Animation1=[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
Animation1.duration=0.2;
Animation1.repeatCount=INFINITY;
Animation1.autoreverses=YES;
Animation1.fromValue=[NSNumber numberWithFloat:0];
Animation1.toValue=[NSNumber numberWithFloat:-10];
[[AnimView2 layer] addAnimation:Animation1 forKey:@"shakeAnim"];

//rotating
CABasicAnimation *Animation2;
Animation2=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
Animation2.duration=0.2;
Animation2.repeatCount=INFINITY;
Animation2.autoreverses=YES;
Animation2.fromValue=[NSNumber numberWithFloat:0];
Animation2.toValue=[NSNumber numberWithFloat:M_PI/4];
[[AnimView3 layer] addAnimation:Animation2 forKey:@"rotateAnim"];

//fade
CABasicAnimation *animation3 = [CABasicAnimation animationWithKeyPath:@"opacity"];
animation3.duration=0.5;
animation3.repeatCount=INFINITY;
animation3.autoreverses=YES;
animation3.fromValue=[NSNumber numberWithFloat:1];
animation3.toValue=[NSNumber numberWithFloat:0];
[[AnimView4 layer] addAnimation:animation3 forKey:@"fadeAnim"]; 


Highlight Text in UIWebView using JavaScript:


[webView stringByEvaluatingJavaScriptFromString:@"var range = window.getSelection().getRangeAt(0);"
    @"var selectionContents = range.extractContents();"
    @"var span = document.createElement('span');"
    @"span.style.backgroundColor = 'yellow';"
    @"span.appendChild(selectionContents);"
    @"range.insertNode(span)" ];


Text field accept user required characters only


- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string  {

    NSString *acceptedCharacters=@"AEIOU12345"; // only these characters  will be allowed to be displayed in text filed.
    NSCharacterSet *cs = [[NSCharacterSet characterSetWithCharactersInString:acceptedCharacters] invertedSet];

    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs] componentsJoinedByString:@""];

    return [string isEqualToString:filtered];
}


Taking screenshot programmatically in iOS 7



UIScreen *screen = [UIScreen mainScreen] ;
UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];

UIView *view = [screen snapshotViewAfterScreenUpdates:YES];

UIGraphicsBeginImageContextWithOptions(screen.bounds.size, NO, 0);
[keyWindow drawViewHierarchyInRect:keyWindow.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

NSData *data= UIImagePNGRepresentation(image);
[data writeToFile:[NSString stringWithFormat:@"%@/ScreenShot.png",[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]] atomically:YES];



UIActivityIndicatorView at the Center of View with AutoLayout



UIActivityIndicatorView at the Center of View with AutoLayout


 UIActivityIndicatorView  *spinner;
spinner =[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
[spinner setTranslatesAutoresizingMaskIntoConstraints:NO];
spinner.color=[UIColor blackColor];
    [self.view addSubview:spinner];

 NSLayoutConstraint *cont = [NSLayoutConstraint constraintWithItem:spinner attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterX multiplier:1.0 constant:0.0];
    [self.view addConstraint:cont];

 cont = [NSLayoutConstraint constraintWithItem:spinner attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self.view attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0.0];

    [self.view addConstraint:cont];

Display HTML with NSAttributedString



NSString *html = @"Wow! Now iOS can create

NSAttributedString

from HTMLs!";
NSDictionary *options = @{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType};

NSAttributedString *attrString = [[NSAttributedString alloc] initWithData:[html dataUsingEncoding:NSUTF8StringEncoding] options:options documentAttributes:nil error:nil];

NSData *htmlData = [attrString dataFromRange:NSMakeRange(0, [attrString length]) documentAttributes:options error:nil];
NSString *htmlString = [[NSString alloc] initWithData:htmlData encoding:NSUTF8StringEncoding];

============================================================


NSString *htmlString = [[NSAttributedString alloc] initWithData:[htmlString dataUsingEncoding:NSUTF8StringEncoding]
                                 options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
                                           NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding)}
                      documentAttributes:nil error:nil];
                     
                     

Detect blinks and smiles with CoreImage


UIImage *image = [UIImage imageNamed:@"myImage"];
CIDetector *detector = [CIDetector detectorOfType:CIDetectorTypeFace
                                          context:nil
                                          options:@{CIDetectorAccuracy: CIDetectorAccuracyHigh}];

NSDictionary *options = @{ CIDetectorSmile: @YES, CIDetectorEyeBlink: @YES };

NSArray *features = [detector featuresInImage:image.CIImage options:options];

for (CIFaceFeature *feature in features) {
    NSLog(@"Bounds: %@", NSStringFromCGRect(feature.bounds));

    if (feature.hasSmile) {
    NSLog(@"Nice smile!");
    } else {
    NSLog(@"Why so serious?");
    }
    if (feature.leftEyeClosed || feature.rightEyeClosed) {
    NSLog(@"Open your eyes!");
    }
}

Base64 Encoding and Decoding



NSData* sampleData = [@"Some sample data" dataUsingEncoding:NSUTF8StringEncoding];


Base64 Encoding:
================
NSString * base64String = [sampleData base64EncodedStringWithOptions:0];
NSLog(@"Base64-encoded string is %@", base64String); // prints "U29tZSBzYW1wbGUgZGF0YQ=="


Base64 Decoding:
================
NSData* dataFromString = [[NSData alloc] initWithBase64EncodedString:base64String options:0];
NSLog(@"String is %@",[NSString stringWithUTF8String:[dataFromString bytes]]); // prints "Some sample data"

Blur Effect using CoreImage


Add CoreImge.framework


UIImage *theImage = [UIImage imageNamed:@"Sample.png"];

    //create our blurred image
    CIContext *context = [CIContext contextWithOptions:nil];
    CIImage *inputImage = [CIImage imageWithCGImage:theImage.CGImage];

    //setting up Gaussian Blur (we could use one of many filters offered by Core Image)
    CIFilter *filter = [CIFilter filterWithName:@"CIGaussianBlur"];
    [filter setValue:inputImage forKey:kCIInputImageKey];
    [filter setValue:[NSNumber numberWithFloat:15.0f] forKey:@"inputRadius"];
    CIImage *result = [filter valueForKey:kCIOutputImageKey];
    //CIGaussianBlur has a tendency to shrink the image a little, this ensures it matches up exactly to the bounds of our original image
    CGImageRef cgImage = [context createCGImage:result fromRect:[inputImage extent]];

self.imageView.image=[UIImage imageWithCGImage:cgImage];

CoreImage Filters


First you need to import and link with the CoreImage.framework

UIImage* inputImage = [UIImage imageNamed:@"image.jpg"];
CIImage* filterInputImage = [CIImage imageWithCGImage:inputImage.CGImage];

CIFilter* filter = [CIFilter filterWithName:@"CIDotScreen"];
[filter setValue:filterInputImage forKey:kCIInputImageKey];

CIImage* filterOutputImage = filter.outputImage;

To make it back into a UIImage, a CIContext needs to be used, as so

CIContext* ctx = [CIContext contextWithOptions:nil];
CGImageRef createdImage = [ctx createCGImage:filterOutputImage fromRect:filterOutputImage.extent];

UIImage* outputImage = [UIImage imageWithCGImage:createdImage];

CGImageRelease(createdImage);
createdImage = nil;


==========================================================

NSLog(@"%@", [CIFilter filterNamesInCategory:kCICategoryBuiltIn]);

(
    CIAdditionCompositing,
    CIAffineClamp,
    CIAffineTile,
    CIAffineTransform,
    CIBarsSwipeTransition,
    CIBlendWithMask,
    CIBloom,
    CIBumpDistortion,
    CIBumpDistortionLinear,
    CICheckerboardGenerator,
    CICircleSplashDistortion,
    CICircularScreen,
    CIColorBlendMode,
    CIColorBurnBlendMode,
    CIColorControls,
    CIColorCube,
    CIColorDodgeBlendMode,
    CIColorInvert,
    CIColorMap,
    CIColorMatrix,
    CIColorMonochrome,
    CIColorPosterize,
    CIConstantColorGenerator,
    CICopyMachineTransition,
    CICrop,
    CIDarkenBlendMode,
    CIDifferenceBlendMode,
    CIDisintegrateWithMaskTransition,
    CIDissolveTransition,
    CIDotScreen,
    CIEightfoldReflectedTile,
    CIExclusionBlendMode,
    CIExposureAdjust,
    CIFalseColor,
    CIFlashTransition,
    CIFourfoldReflectedTile,
    CIFourfoldRotatedTile,
    CIFourfoldTranslatedTile,
    CIGammaAdjust,
    CIGaussianBlur,
    CIGaussianGradient,
    CIGlideReflectedTile,
    CIGloom,
    CIHardLightBlendMode,
    CIHatchedScreen,
    CIHighlightShadowAdjust,
    CIHoleDistortion,
    CIHueAdjust,
    CIHueBlendMode,
    CILanczosScaleTransform,
    CILightenBlendMode,
    CILightTunnel,
    CILinearGradient,
    CILineScreen,
    CILuminosityBlendMode,
    CIMaskToAlpha,
    CIMaximumComponent,
    CIMaximumCompositing,
    CIMinimumComponent,
    CIMinimumCompositing,
    CIModTransition,
    CIMultiplyBlendMode,
    CIMultiplyCompositing,
    CIOverlayBlendMode,
    CIPinchDistortion,
    CIPixellate,
    CIRadialGradient,
    CIRandomGenerator,
    CISaturationBlendMode,
    CIScreenBlendMode,
    CISepiaTone,
    CISharpenLuminance,
    CISixfoldReflectedTile,
    CISixfoldRotatedTile,
    CISmoothLinearGradient,
    CISoftLightBlendMode,
    CISourceAtopCompositing,
    CISourceInCompositing,
    CISourceOutCompositing,
    CISourceOverCompositing,
    CIStarShineGenerator,
    CIStraightenFilter,
    CIStripesGenerator,
    CISwipeTransition,
    CITemperatureAndTint,
    CIToneCurve,
    CITriangleKaleidoscope,
    CITwelvefoldReflectedTile,
    CITwirlDistortion,
    CIUnsharpMask,
    CIVibrance,
    CIVignette,
    CIVortexDistortion,
    CIWhitePointAdjust
)


Interactive Notifications in iOS 8


In iOS 8 developers can now present interactive notifications in their apps.

To do so, first you need to register all possible notification “categories”. A category is defined by a set of actions. In my example I’m going to setup a category with reply and delete actions

Each action is shown to the user as a button. Actions have two possible activation modes: foreground or background. If your app can perform the action with no further interaction from the user then you want to use the background activation mode. If the action needs further user input then you can set the activation mode to foreground to have your app launched when actioned, for example, presenting a keyboard in your app when they reply button is tapped.




UIMutableUserNotificationAction* deleteAction = [[UIMutableUserNotificationAction alloc] init];
[deleteAction setIdentifier:@"delete_action_id"];
[deleteAction setTitle:@"Delete"];
[deleteAction setActivationMode:UIUserNotificationActivationModeBackground];
[deleteAction setDestructive:YES];

UIMutableUserNotificationAction* replyAction = [[UIMutableUserNotificationAction alloc] init];
[replyAction setIdentifier:@"reply_action_id"];
[replyAction setTitle:@"Reply"];
[replyAction setActivationMode:UIUserNotificationActivationModeForeground];
[replyAction setDestructive:NO];

UIMutableUserNotificationCategory* deleteReplyCategory = [[UIMutableUserNotificationCategory alloc] init];
[deleteReplyCategory setIdentifier:@"custom_category_id"];
[deleteReplyCategory setActions:@[replyAction, deleteAction] forContext:UIUserNotificationActionContextDefault];


NSSet* categories = [NSSet setWithArray:@[deleteReplyCategory]];
UIUserNotificationSettings* settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:categories];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];


Now we can schedule a notification to use the previously setup category. This is the string identifier from before. This notification is scheduled after 10 seconds.

UILocalNotification* notification = [[UILocalNotification alloc] init];
[notification setFireDate:[NSDate dateWithTimeIntervalSinceNow:10]];
[notification setAlertBody:@"Somebody sent you a message"];
[notification setCategory:@"custom_category_id"];
[[UIApplication sharedApplication] scheduleLocalNotification:notification];


When the user selects an option we get a callback to the app delegate.


- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forLocalNotification:(UILocalNotification *)notification completionHandler:(void(^)())completionHandler
{
    if([notification.category isEqualToString:@"custom_category_id"])
    {
        if([identifier isEqualToString:@"delete_action_id"])
        {
            NSLog(@"Delete was pressed");
        }
        else if([identifier isEqualToString:@"reply_action_id"])
        {
            NSLog(@"Reply was pressed");
        }
    }
   
    //    Important to call this when finished
    completionHandler();
}






-viewWillAppear in iOS 7.0



- (void) viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    const BOOL isInteractivePop = (self.navigationController.interactivePopGestureRecognizer.state == UIGestureRecognizerStateBegan);

    if(isInteractivePop)
    {
        //    Interactive pop stuff
    }
    else
    {
        //    Back button stuff
    }
}

iOS7 interactivePopGestureRecognizer for UINavigationController with hidden navigation bar

iOS7 introduces interactivePopGestureRecognizer property which is used for popping current view controller stack by a gesture (swipe right gesture from left edge as default). However if the navigation bar is hidden or the app uses a custom back button for navigation bar, this feature will not work. A bit lines of code can make this feature works again for those cases. In viewDidLoad() of view controller (or application:didFinishLaunchingWithOptions: of AppDelegate), we set the interactivePopGestureRecognizer.delegate to nil as below:

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1) {
  self.navigationController.interactivePopGestureRecognizer.delegate = nil;
}


interactivePopGestureRecognizer in UINavigationController



- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    // Disable iOS 7 back gesture
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
        self.navigationController.interactivePopGestureRecognizer.delegate = self;
    }
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];

    // Enable iOS 7 back gesture
    if ([self.navigationController respondsToSelector:@selector(interactivePopGestureRecognizer)]) {
        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
        self.navigationController.interactivePopGestureRecognizer.delegate = nil;
    }
}

- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
{
    return NO;
}

Tuesday, December 23, 2014

iPhone UI Designs Tips:


http://www.lovelyui.com/

http://www.mobile-patterns.com/

http://www.pttrns.com/