Posted By

sag333ar on 11/18/10


Tagged

Objective-c iphone ios iOS40


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

sag333ar
Tintenklecks
cnathan


To check iOS4.0 or not


 / Published in: Objective C
 

  1. #import <MobileCoreServices/UTCoreTypes.h>
  2.  
  3. #define SOURCETYPE UIImagePickerControllerSourceTypeCamera
  4.  
  5. -(void)saveImageInBackGround{
  6. Class aMsgClass = NSClassFromString(@"MFMessageComposeViewController");
  7.  
  8. // following will check
  9. // if user has device higher then equal to 3GS
  10. // and using iPhone os higher then iOS 4.0 (multitasking)
  11.  
  12. if(aMsgClass && [UIImagePickerController isSourceTypeAvailable:SOURCETYPE]){
  13.  
  14. NSArray *mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:SOURCETYPE];
  15. bool isA3GS = [mediaTypes containsObject:kUTTypeMovie];
  16.  
  17. if(isA3GS){
  18. // NSLog(@"yep 3gs and more");
  19. UIImageWriteToSavedPhotosAlbum(self.imgBig, nil, nil, nil);
  20. } else {
  21. // NSLog(@"nop ! Sorry compressed image will be saved.");
  22. // if it's not a 3GS or higher device.
  23. // first compress image
  24. UIImage *img=[UIImage imageWithData:UIImageJPEGRepresentation(self.smallImage, 0.59)];
  25. // then save it to photo album.
  26. UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
  27. // this statement will take time to execute.
  28. }
  29. } else {
  30. // NSLog(@"nop ! Sorry compressed image will be saved.");
  31. // first compress image
  32. UIImage *img=[UIImage imageWithData:UIImageJPEGRepresentation(self.smallImage, 0.59)];
  33. // then save it to photo album.
  34. UIImageWriteToSavedPhotosAlbum(img, nil, nil, nil);
  35. // this statement will take time to execute.
  36. }
  37. }

Report this snippet  

You need to login to post a comment.