Skip to main content

Posts

Showing posts from October, 2012

iOS Dev: Access Address Book in iOS6 (Permission)

In iOS 6 :  Access the Address Book details by this code: -(BOOL)isABAddressBookCreateWithOptionsAvailable {    return &ABAddressBookCreateWithOptions != NULL; } your method code :{ CFErrorRef error = NULL; ABAddressBookRef addressBook ; //ABAddressBookRef addressBook = ABAddressBookCreate(); if ([self isABAddressBookCreateWithOptionsAvailable]) {    addressBook = ABAddressBookCreateWithOptions(NULL,&error);   ABAddressBookRequestAccessWithCompletion(addressBook, ^(bool granted, CFErrorRef error) { // callback can occur in background, address book must be accessed on thread it was created on    dispatch_async(dispatch_get_main_queue(), ^{         if (error) {                       NSLog(@"error == %@",error);        } else if (!granted) {  ...

iOS Dev: Apple iOS 6 Orientataion Problem

Here the solution: From Apple's iOS 6 SDK Release Notes: Autorotation is changing in iOS 6. In iOS 6, the shouldAutorotateToInterfaceOrientation: method of UIViewController is deprecated . In its place, you should use the supportedInterfaceOrientationsForWindow: and shouldAutorotate methods. More responsibility is moving to the app and the app delegate. Now, iOS containers (such as UINavigationController) do not consult their children to determine whether they should autorotate. By default, an app and a view controller’s supported interface orientations are set to UIInterfaceOrientationMaskAll for the iPad idiom and UIInterfaceOrientationMaskAllButUpsideDown for the iPhone idiom . A view controller’s supported interface orientations can change over time—even an app’s supported interface orientations can change over time. The system asks the top-most full-screen view controller (typically the root view controller) for its supported interface orientations whene...

iOS Dev: Apple’s iOS 6 beta 3 changes

Apple has seeded iOS 6 beta 3 to developers, and here is the change log directly from Apple’s developer portal: Notes and Known Issues The following issues relate to using iOS SDK 6.0 to develop code. Address Book When an app is in a fresh privacy state and tries to present a ABNewPersonViewController , the user cannot dismiss that view controller properly even if they allow access to contacts. The user must force quit the app and relaunch. Requesting access to contacts: Users are able to grant or deny access to contact data on a per-app basis. To request access to contact data, call the ABAddressBookRequestAccessWithCompletion function after calling the ABAddressBookCreateWithOptions function. The ABAddressBookRequestAccessWithCompletion function does not block the app while the user is being asked to grant or deny access. Until access has been granted, the ABAddressBookRef object will not contain any contacts and any attempt to modify contacts fails with a kABOpera...

iOSDev: Saving and Getting Image from NSDocumentDirectory (get image from URL)

Look the Code" //Getting the image from URL -(void)savedPhotoInDocDir:(NSString *) imageURL{ NSData *imageData = [NSData dataWithContentsOfURL:[NSURL URLWithString:imageURL]]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString *documentsDir = [paths objectAtIndex:0]; //TimeStamp getting random number int randomNumber = [self getRandomNumber:9 to:9999999999]; //Creating Time stamp for specific name of save Image NSString * timeStampValue = [NSString stringWithFormat:@"%ld", (long)[[NSDate date] timeIntervalSince1970]]; [self setImagePath:[documentsDir stringByAppendingPathComponent:[NSString stringWithFormat:@"savePhoto%@%d.png",timeStampValue,randomNumber]]]; BOOL isDone =[fileManager createFileAtPath:imagePath contents:imageData attributes:nil]; if(isDone==TRUE){ NSLog(@"Saved Image Document Directory"); } else { NSL...

iOS Dev: UIImage Orientaion Code

// method for swipe static CGRect swapWidthAndHeight(CGRect rect) { CGFloat swap = rect.size.width; rect.size.width = rect.size.height; rect.size.height = swap; return rect; } #pragma mark - rotateImage captured -(UIImage*)rotateImageOrien:(UIImageOrientation)orient andImage:(UIImage *)img { CGRect bnds = CGRectZero; UIImage* copy = nil; CGContextRef ctxt = nil; CGImageRef imag = img.CGImage; CGRect rect = CGRectZero; CGAffineTransform tran = CGAffineTransformIdentity; rect.size.width = CGImageGetWidth(imag); rect.size.height = CGImageGetHeight(imag); bnds = rect; switch (orient) { case UIImageOrientationUp: // would get you an exact copy of the original //assert(false); return nil; case UIImageOrientationUpMirrored: tran = CGAffineTransformMakeTranslation(rect.size.width, 0.0); tran = CGAffineTransformScale(tran, -1.0, 1.0); break; case UIImageOrientationDown: tran = CGAffineTransformMakeTranslation(rect.size.width, rect.size.height); tran = CGAffineT...