uiimagepickercontroller

How to make UIImagePickerController for camera and photo library at the same time in swift

女生的网名这么多〃 提交于 2019-11-26 15:31:44
问题 I use UIImagePickerController to take a photo by camera of iPhone. I want to show both "take a photo" and "choose a photo". My code imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = .camera //imagePicker.sourceType = .PhotoLibrary presentViewController(imagePicker, animated: true, completion: nil) I tried to use imagePicker.sourceType = .Camera and imagePicker.sourceType = .PhotoLibrary together to do this, but it doesn't work... Thank you 回答1:

Resizing UIimages pulled from the Camera also ROTATES the UIimage?

ぃ、小莉子 提交于 2019-11-26 15:04:35
I am getting UIimages from the camera and assigning them to UIImageViews to be displayed. When I do this the camera gives me a 1200 x 1600 pixel image which I then assign to a UIImageView in my Application. The image is displayed as expected in the image view under this condition. However, when I attempt to RESIZE the retrieved UIImage before assigning it to the UIImageView, the image is resizing as expected but there IS a problem in that somewhere (in the RESIZING code?) my UIImage is getting ROTATED... As a result, when I assign the resized UIImage to a UIImageView the image is rotated 90

Getting “Using two-stage rotation animation” warning with UIImagePickerController

↘锁芯ラ 提交于 2019-11-26 13:52:28
问题 I wrote simple code to test UIImagePickerController: @implementation ProfileEditViewController - (void)viewDidLoad { [super viewDidLoad]; photoTaker_ = [[UIImagePickerController alloc] init]; photoTaker_.delegate = self; photoTaker_.sourceType = UIImagePickerControllerSourceTypeCamera; photoTaker_.showsCameraControls = NO; } - (void)viewDidAppear: (BOOL)animated { [self presentModalViewController: photoTaker_ animated: NO]; } @end And I'm getting strange warnings like the following: 2010-05

iOS 7 UIImagePicker preview black screen

我与影子孤独终老i 提交于 2019-11-26 13:45:21
问题 When i try to load camera from my code, camera preview is black. If I wait for 10-20 seconds it will show real camera preview. I found several questions and some of them suggest that running some other code in background should be the reason for this. However I don't have any code running in background. How should I fix this? This is my code where I run camera UIImagePickerController *photoPicker = [[UIImagePickerController alloc] init]; photoPicker.delegate = self; photoPicker.sourceType =

iPhone - UIImagePickerControllerDelegate inheritance

 ̄綄美尐妖づ 提交于 2019-11-26 13:44:06
问题 I have added a UIImagePickerController to a UIViewController . I have also assigned the UIImagePickerControllerDelegate to that UIViewController . When I execute the following line, myPicker.delegate = self; Xcode gifts me with the following message: warning: assigning to id from incompatible type 'RootViewController' Then I added the UINavigationControllerDelegate protocol to the same UIViewController and the error message vanished. So, do I have to add both protocols to the UIViewController

How to open the ImagePicker in SwiftUI?

蹲街弑〆低调 提交于 2019-11-26 13:18:56
问题 I need to open the ImagePicker in my app using SwiftUI, how can I do that? I thought about using the UIImagePickerController, but I don't know how to do that in SwiftUI. 回答1: Here's a "rough around the edges" implementation. You need to wrap UIImagePickerController in a struct implementing UIViewControllerRepresentable . For more about UIViewControllerRepresentable , please check this amazing WWDC 2019 talk: Integrating SwiftUI struct ImagePicker: UIViewControllerRepresentable { @Environment(

PresentViewController from custom TableCell in xib

我只是一个虾纸丫 提交于 2019-11-26 12:31:12
问题 I\'ve created custom tableView Controller, inside the cell i\'ve placed a button to open the device photo library. My problem, i cant able to open imagePickerController from CustomCell.m, its shows below error. Please give some idea to fix my issue. 回答1: TableViewCell is a view, you can not present on views instead UIViewController can handle it. You should transfer the control from your cell to your controller that holds tableview and creates custom cell for it. Try like this: Custom Cell .h

Save Photos to Custom Album in iPhones Photo Library

戏子无情 提交于 2019-11-26 11:51:13
问题 I\'m trying to create a custom album in the Photo Library of an iPhone and then save photos that I\'ve taken with the camera, or chosen from the phones Camera Roll to that custom album. I can successfully create the album but the photos are not getting saved there, instead they are getting saved to the simulators Saved Photos album... I\'m not sure how to tell UIImageWriteToSavedPhotosAlbum to save to the new album I\'ve just created using addAssetsGroupAlbumWithName ... Here is the code I

Can I load a UIImage from a URL?

社会主义新天地 提交于 2019-11-26 11:34:58
I have a URL for an image (got it from UIImagePickerController) but I no longer have the image in memory (the URL was saved from a previous run of the app). Can I reload the UIImage from the URL again? I see that UIImage has a imageWithContentsOfFile: but I have a URL. Can I use NSData's dataWithContentsOfURL: to read the URL? EDIT1 based on @Daniel's answer I tried the following code but it doesn't work... NSLog(@"%s %@", __PRETTY_FUNCTION__, photoURL); if (photoURL) { NSURL* aURL = [NSURL URLWithString:photoURL]; NSData* data = [[NSData alloc] initWithContentsOfURL:aURL]; self.photoImage =

Swift PNG Image being saved with incorrect orientation

老子叫甜甜 提交于 2019-11-26 11:24:48
If I use the image before it is saved it is normal. But if I save it and use it later is is 90 degrees turned. How can I make sure it doesn't save sideways? func saveEvent(_ center1: CLLocation, title2: String, imagePicked1: UIImage) { let data = UIImagePNGRepresentation(imagePicked1);/// let url = NSURL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(NSUUID().uuidString+".dat") do { try data!.write(to: url!, options: []) } catch let e as NSError { print("Error! \(e)"); return } let image11 = CKAsset(fileURL: url!) self.eventRecord.setObject(image11 as CKAsset, forKey: "Picture