Sunday 10 November 2013

Reload UITableView with animation

[tableView reloadData];
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromBottom];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[animation setFillMode:kCAFillModeBoth];
[animation setDuration:.3];
[[tableView layer] addAnimation:animation forKey:@"UITableViewReloadDataAnimationKey"];    

Thursday 7 November 2013

Checking for iPad or iPhone

if ([[UIDevice currentDevice].model rangeOfString:@"iPad"].location!=NSNotFound)
    {
        //ipad
    }
    else
    {
       //iphone
    }

Wednesday 6 November 2013

IOS UIButtion with animated gif Image

UIImageView* animatedImageView = [[UIImageView alloc] initWithFrame:self.view.bounds];
animatedImageView.animationImages = [NSArray arrayWithObjects:    
                               [UIImage imageNamed:@"image1.png"],
                               [UIImage imageNamed:@"image2.png"],
                               [UIImage imageNamed:@"image3.png"],
                               [UIImage imageNamed:@"image4.png"], nil];
animatedImageView.animationDuration = 1.0f;
animatedImageView.animationRepeatCount = 0;
[animatedImageView startAnimating];
[yourButton addSubview: animatedImageView];

Friday 1 November 2013

JSON string From NSDictionary

NSDictionary *jsondict;

NSData *jsonData=[NSJSONSerialization dataWithJSONObject:jsondict options:NSJSONWritingPrettyPrinted error:Nil];

NSString *jsonStr=[[NSString alloc]initWithData: jsonData encoding:NSUTF8StringEncoding];


 jsonStr =[jsonStr stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];