Thursday, 24 April 2014

Rotate UIView or UIImageView with this bellow code.

 For use this code import QuartzCore framework like bellow

#import <QuartzCore/QuartzCore.h>   

and then use bellow code

   CABasicAnimation *theAnimation;
    theAnimation=[CABasicAnimation animationWithKeyPath:@"transform.rotation"];
    theAnimation.duration=1.0; // Animation duration
    theAnimation.repeatCount=1; // no of times you want to do animation
    theAnimation.autoreverses=YES; // reverses the animation
    theAnimation.fromValue=[NSNumber numberWithFloat:0.0]; // initial stage of animation
    theAnimation.toValue=[NSNumber numberWithFloat:3.0]; // rotation angle

    [yourImageView.layer addAnimation:theAnimation forKey:@"animateRotation"]; // add animation to thelayer of a view for which you want animation.

Thursday, 17 April 2014

open mapview with any address name from iphone application to apple map application

with bellow code you can open any location with its name to apple's mapview application with bellow code..

//    [[MKMapItem mapItemForCurrentLocation] openInMapsWithLaunchOptions:nil];// you can open user current location with this 1 line  

    Class mapItemClass = [MKMapItem class];
    if (mapItemClass && [mapItemClass respondsToSelector:@selector(openMapsWithItems:launchOptions:)])
        CLGeocoder *geocoder = [[CLGeocoder alloc] init];
        [geocoder geocodeAddressString:yourAddressText
                     completionHandler:^(NSArray *placemarks, NSError *error) {
                         // Convert the CLPlacemark to an MKPlacemark
                         // Note: There's no error checking for a failed geocode
                         CLPlacemark *geocodedPlacemark = [placemarks objectAtIndex:0];
                         MKPlacemark *placemark = [[MKPlacemark alloc]
                         // Create a map item for the geocoded address to pass to Maps app
                         MKMapItem *mapItem = [[MKMapItem alloc] initWithPlacemark:placemark];
                         [mapItem openInMapsWithLaunchOptions:nil];


Load URL in UIWebView with special character , append some string with bellow code.

Here you can add any code or string in your local file url with bellow code.

if your url like user/.../filename.htm and if you want to add some hash code of word after that url like user/.../filename.htm#green then you can use my bellow function.

    NSString *path;
NSBundle *thisBundle = [NSBundle mainBundle];
path = [thisBundle pathForResource:@"filename" ofType:@"html"];//here write your file name and its extention
    NSURL *url = [NSURL fileURLWithPath:path];
    NSURL *fullURL = [NSURL URLWithString:@"#green" relativeToURL:url];//pass any code or string with append in url baseurl like this
    [yourWebView loadRequest:[NSURLRequest requestWithURL:fullURL]];
    [yourWebView setBackgroundColor:[UIColor clearColor]];
    [yourWebView setOpaque:NO];