Skip to main content

Posts

Showing posts from October, 2012

ThumbNail of PDF

-( void )thumbnailOfPDF{     NSURL * pdfFileUrl = [ NSURL fileURLWithPath :[[ NSBundle mainBundle ] pathForResource : @"test" ofType : @"pdf" ]];     CGPDFDocumentRef pdf = CGPDFDocumentCreateWithURL (( CFURLRef ) CFBridgingRetain (pdfFileUrl));     CGPDFPageRef page;          CGRect aRect = CGRectMake ( 0 , 0 , 70 , 100 ); // thumbnail size     UIGraphicsBeginImageContext (aRect. size );     CGContextRef context = UIGraphicsGetCurrentContext ();     UIImage* thumbnailImage;               NSUInteger totalNum = CGPDFDocumentGetNumberOfPages (pdf);          [ self . thumbScrollView setContentSize : CGSizeMake ( self . thumbScrollView . frame . size . width , totalNum* 100 )];     for ( int i = 0 ; i < totalNum; i++ ) {                           UIImageView *showThumbnail = [[ UIImageView alloc ] initWithFrame : CGRectMake ( 0 , 100 *i, 80 , 80 )];         [showThumbnail setBackgroundColor :[ UIColor redCo

GCD Example

test.h { dispatch_queue_t backgroundQueue ; } test.m - ( void )viewDidLoad {     [ super viewDidLoad ];    //com.unique.uniqueidentifier.youtube is any unique name     backgroundQueue = dispatch_queue_create ( "com.unique.uniqueidentifier.youtube" , NULL );      } -(void)anyFunction {        dispatch_async ( backgroundQueue , ^( void ){              [ self sendRequestForData ];        }); } -( void )sendRequestForData {     NSString *post = @"" ;     NSData *postData = [post dataUsingEncoding : NSISOLatin1StringEncoding allowLossyConversion : NO ];     NSMutableURLRequest *urlRequest = [[[ NSMutableURLRequest alloc ] init ] autorelease ];     [urlRequest setURL :[ NSURL URLWithString: < any url string for fetching data from server> ]];     [urlRequest setHTTPMethod : @"GET" ];      [urlRequest setHTTPBody :postData];     NSData *urlDa

Resume application after call through application

Resume application after call through application: //Call from any button Click -(void)call{        [ self callWithOutExitApplication :[ NSString stringWithFormat : @"+%@" ,@"123456789"]] } -( void )callWithOutExitApplication:( NSString *)pPhoneNumber{         NSURL * callURL = [ NSURL URLWithString :[ NSString stringWithFormat : @"tel://%@" ,pPhoneNumber]];                    // Make sure device supports phone functionality.          if ([[ UIApplication sharedApplication ] canOpenURL :callURL]){                  if (callURL){                                                    NSString *osVersion = [[ UIDevice currentDevice ] systemVersion ];                                                    if ([osVersion floatValue ] >= TEL_OS_VERSION ) {                                  // To resume the application after call is disconnected, initiate the call using the webview (Work arou