Skip to main content

Posts

Add Navigation bar background images

NOTE : Add this on the top of the delegate file before implementation of class. @implementation UINavigationBar (UINavigationBarCategory) -(void)setBackgroundImage:(UIImage*)image withTag:(NSInteger)bgTag{     if(image == NULL){ //might be called with NULL argument         return;     }     UIImageView *aTabBarBackground = [[UIImageView alloc]initWithImage:image];     aTabBarBackground.frame = CGRectMake(0,0,self.frame.size.width,self.frame.size.height);     aTabBarBackground.tag = bgTag;     [self addSubview:aTabBarBackground];     [self sendSubviewToBack:aTabBarBackground];     [aTabBarBackground release]; } /* input: The tag you chose to identify the view */ -(void)resetBackground:(NSInteger)bgTag {     [self sendSubviewToBack:[self viewWithTag:bgTag]]; } - (void)drawLayer:(CALayer *)layer inCo...

Latitude Longitude with the help of address

- ( CLLocationCoordinate2D ) geoCodeUsingAddress :( NSString *) address {     double latitude = 0 , longitude = 0 ;     NSString * esc_addr =   [ address stringByAddingPercentEscapesUsingEncoding : NSUTF8StringEncoding ];     NSString * req = [ NSString stringWithFormat :@ "http://maps.google.com/maps/api/geocode/json?sensor=false&address=%@" , esc_addr ];     NSString * result = [ NSString stringWithContentsOfURL :[ NSURL URLWithString : req ] encoding : NSUTF8StringEncoding error : NULL ];     if ( result ) {         NSScanner * scanner = [ NSScanner scannerWithString : result ];         if ([ scanner scanUpToString :@ "\"lat\":" intoString : nil ] && [ scanner scanString :@ "\"lat\":" intoString : nil ]) {             [ scanner scanDouble :& latitude ];             if ([ scanner...

Write PDF in the Document Directory

NSString *urlString = @"http://www.web.com/url/for/document.pdf"; NSURL *url = [NSURL URLWithString:urlString]; NSData *data = [NSData dataWithContentsOfURL:url]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDirectory = [paths objectAtIndex:0]; NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@"myLocalFileName.pdf"]; [data writeToFile:pdfPath atomically:YES];

Add Loader in The application

-( UIView *)initLoader { UIView *indicatiorView = [[ UIView alloc ] initWithFrame : CGRectMake ( 0 , 0 , 320 , 480 )]; indicatiorView. backgroundColor = [ UIColor clearColor ]; indicatiorView. alpha = 0.8 ; UIView *blackView=[[ UIView alloc ] initWithFrame : CGRectMake ( 85 , 200 , 150 , 60 )]; blackView. backgroundColor =[ UIColor blackColor ]; blackView. layer . cornerRadius = 10 ; UILabel *reloadingLabel=[[ UILabel alloc ] initWithFrame : CGRectMake ( 0 , 0 , 150 , 25 )]; reloadingLabel. text = @"Please Wait..." ; reloadingLabel. textAlignment = UITextAlignmentCenter ; reloadingLabel. textColor =[ UIColor whiteColor ]; reloadingLabel. font =[ UIFont boldSystemFontOfSize : 16 ]; reloadingLabel. backgroundColor =[ UIColor clearColor ]; [blackView addSubview :reloadingLabel]; [reloadingLabel release ]; UIActivityIndicatorView *indicatorView = [[ UIActivityIndicatorView alloc ] initWithFrame : CGRectMake ( 65 , 30 , 22 , 22 )]; indicatorView. a...