24323

Uiimage as photolibrary file or camera

Question:

I want to select a image from Photo library or camera and have to save it into my photo album(If its already there i want to put 1 more copy)

-(IBAction) getPhoto:(id) sender { UIImagePickerController * picker = [[UIImagePickerController alloc] init]; picker.delegate = self; if((UIButton *) sender == choosePhotoBtn) { picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary; } else { picker.sourceType = UIImagePickerControllerSourceTypeCamera; } [self presentModalViewController:picker animated:YES]; } -(IBAction) savePhoto:(id) sender { UIImage *myImage =UIImagePickerControllerSourceTypePhotoLibrary||UIImagePickerControllerSourceTypeCamera UIImageWriteToSavedPhotosAlbum(myImage, self, @selector(image:didFinishSavingWithError:contextInfo:), nil); printf("Hello world"); }

Here my savePhoto function os not working

Answer1:

UIImage *myImage =UIImagePickerControllerSourceTypePhotoLibrary||UIImagePickerControllerSourceTypeCamera

I don't know what it's doing here. In C / C++ the || operator always returns a bool (int), so it's definitely not an UIImage.

If the image picked from the UIImagePickerController is needed, implement the -imagePickerController:didFinishPickingMediaWithInfo: method for the delegate, then read the UIImagePickerControllerEditedImage key of the info.

If a custom image needs to be saved, pass an actual UIImage.

Recommend

  • How to make RESTKit call in iOS continue even if home button is pressed or phone goes into standby
  • Convert Byte Array from Action Script to Image in Java and save it
  • Phonegap ios Camera fails on device not simulator
  • Java- How to use Abstract class
  • ObjC, Facebook Page - posting news feed works, but posting photo does not
  • how to display images in imageview in iphone
  • UIImage slide on/off inside UIImageView iOS
  • Creating a file name by adding two NSStrings
  • Image In Scroll View
  • Change UIbutton Image on click
  • Yelp API ios getting a larger image
  • does c++ have an equivalent boost::numeric_cast(SourceType)?
  • Change UISearchBar background image in iOS11
  • Check existing image in NSDocumentDirectory
  • How to make Images in UITableViewCell scroll smoothly?
  • How to remove zoom slider in UIImagePickerController
  • How to add callout into individual annotation in map view
  • How do you close open files using Swift?
  • Using JQuery Datepicker To Only Show Months
  • Putting text shadow on a UIButton text label
  • How to remove duplicate buttons
  • Customize google placepicker colors for android
  • A simple datepicker in VueJS
  • UIimage to char* conversion
  • UIPickerView without IB?
  • Get UILabel out of UIButton
  • Aligning image on right side of title on UIButton with imageEdgeInsets and titleEdgeInsets
  • Emacs lua-mode issue: (void-function interactively-called-p)
  • Knockout custom binding handler
  • Question about instantiating object
  • NSScanner Loop Question
  • How do I superscript characters in a UIButton?
  • how to save the state in userdefaults of accessory checkmark-iphone
  • MonoTouch: How to download pdf incrementally as indicated in the Apple slides “Building Newsstand Ap
  • Pass value from viewmodel to script in zk
  • Eraser for UIBezierPath
  • Getting 'uninitialized constant' error when using delegate in belongs_to in model
  • Compare two NSDates in iPhone
  • Load html files in TinyMce
  • Suggestions to manage Login/Logout transitions