Search This Blog

Saturday, 27 June 2015

Card Animation Using Facebook POP Framework

Hey!

Hope you all are doing great, and working on some great ideas!

So , i hope everybody heard that a company like FB launched a Framework POP. What it does? It actually allows you to create some nice animations in your app, whereas you may need to do some stuff yourself, so here it is , a card animation using this framework:

It's an animation which will give you an effect like card is thrown on screen(like on table)

ASSUMPTIONS :

1) A UIView which is out of bounds of your screen, and whose angle is changed initially using pop framework code only.In this example that UIView is 'flippercard'.

2) You need to download and setup 'POP Framework'  in your project. It is mentioned at this link: https://github.com/facebook/pop


LETS START:

We will animate this view to come into the bounds of viewcontroller parent view with combination of pop animations to give an effect of card.

a) First import pop framework into your viewcontroller by simply adding '#import "POP.h"'

b) In your '-(void)viewdidload' function copy this code below, this code is responsible to change the initial angle of UIView (flipperCard)


    POPSpringAnimation *rotationAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerRotation];
    rotationAnimation.beginTime = CACurrentMediaTime();
    rotationAnimation.toValue = @(2);
    rotationAnimation.springBounciness = 1;
    rotationAnimation.springSpeed = 4;

    [flipperCard.layer pop_addAnimation:rotationAnimation forKey:@"rotationInitial"];



c) Now , simply copy paste this below function in your view controller.


-(void)animationflipthroughpop{
    
    
    POPBasicAnimation *easin = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPositionY];
    easin.toValue = @(300);
    easin.duration = 0.2;

    POPSpringAnimation *rotationAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerRotation];
    rotationAnimation.beginTime = CACurrentMediaTime();
    rotationAnimation.toValue = @(0);
    rotationAnimation.springBounciness = 0.f;
    rotationAnimation.springSpeed = 0.2;
    [flipperCard.layer pop_addAnimation:rotationAnimation forKey:@"rotationAnim"];
    [flipperCard.layer pop_addAnimation:easin forKey:@"easein"];
   
}


d) Now, simply call this above function in your -(void)viewdidappear:(BOOL)animated function, with a 0.2 seconds delay:

[self performSelector:@selector(animationflipthroughpop) withObject:nil afterDelay:0.2];

     


Run your app, and have fun :)


CHAO!

Monday, 15 June 2015

Get IdentifierForVendor in iOS

Hey!


No talks, just a straight two line code to get identifierForVendor in iOS.


CODE:

    NSUUID *oNSUUID = [[UIDevice currentDevice] identifierForVendor];

    NSString *strApplicationUUID = [oNSUUID UUIDString];


Just for update , i am going to start parse.com tutorials very soon from beginning to advance level! 

Contact me if you need free skype session over this!


Happy programming...
CHAO!

How to get IP Address in iOS

Long time .... sorry for being not available since long. Life you know.... hahahaha !

So, i was looking for some solution to find IP Address in iOS , and to be very frank , i found codes that are useless now with iOS 7, 8 and 9 in market.

I tried NSHost also, but not so appealing to me either.

Here is something i found from anonymous developer, he shared it as a block of code, i created a function, which you my fellow developers, can copy and paste and it will return you the IP.

Simple as it is.....i still remember my promise...Pure code no talks ;)


FUNCTION TO GET IP IN RESPONSE:

-(NSString *) getIPforDevice{
    NSUInteger  an_Integer;
    NSArray * ipItemsArray;
    NSString *externalIP;
    
    NSURL *iPURL = [NSURL URLWithString:@"http://www.dyndns.org/cgi-bin/check_ip.cgi"];
    
    if (iPURL) {
        NSError *error = nil;
        NSString *theIpHtml = [NSString stringWithContentsOfURL:iPURL
                                                       encoding:NSUTF8StringEncoding
                                                          error:&error];
        if (!error) {
            NSScanner *theScanner;
            NSString *text = nil;
            
            theScanner = [NSScanner scannerWithString:theIpHtml];
            
            while ([theScanner isAtEnd] == NO) {
                
                // find start of tag
                [theScanner scanUpToString:@"<" intoString:NULL] ;
                
                // find end of tag
                [theScanner scanUpToString:@">" intoString:&text] ;
                
                // replace the found tag with a space
                //(you can filter multi-spaces out later if you wish)
                theIpHtml = [theIpHtml stringByReplacingOccurrencesOfString:
                             [ NSString stringWithFormat:@"%@>", text]
                                                                 withString:@" "] ;
                ipItemsArray =[theIpHtml  componentsSeparatedByString:@" "];
                an_Integer=[ipItemsArray indexOfObject:@"Address:"];
                
                externalIP =[ipItemsArray objectAtIndex:  ++an_Integer];
                
                
                
            } 
            
            
            NSLog(@"%@",externalIP);
        } else {
            NSLog(@"Oops... g %d, %@"
                  [error code], 
                  [error localizedDescription]);
        }
    }
    return externalIP;

}


Always feel free to ask any queries....

Happy Programming...

CHAO!