I'm trying to make a custom camera view, basically. I am stuck changing the size of the image view inside of the UIImagePicker. By the image view, I mean the window that shows the view of the camera. I hope it will be more clear from the picture. It is the view inside of that red square (I drawed that red square manually to show you, do not think it is from code).
Whatever I tried so far could not help me to change the size of that red rectangular area. Below is what I have so far:
@IBAction func takePhoto(sender: UIButton) {
if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){
imagePicker = UIImagePickerController()
imagePicker.delegate = self
imagePicker.sourceType = .Camera
imagePicker.allowsEditing = false
imagePicker.showsCameraControls = false
//Create view
let customViewController = CustomCameraViewController(
nibName:"CustomCameraViewController",
bundle: nil
)
let customView:CustomCameraView = customViewController.view as! CustomCameraView
//Assignments
customView.frame = self.imagePicker.view.frame
customView.delegate = self
self.imagePicker.cameraOverlayView?.frame.size = customView.image.frame.size
presentViewController(imagePicker,
animated: true,
completion: {
self.imagePicker.cameraOverlayView = customView
}
)
}else{
//Alert
let alert = UIAlertController(title: "Üzgünüz, kameranızı açamadık!", message: "Telefonunuz kamerayı desteklemiyor veya açmamıza izin verilmemiş. İzin vermek isterseniz ayarlardan izni açabilirsiniz.", preferredStyle: UIAlertControllerStyle.Alert)
//Creating actions
let okAction = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default){
UIAlertAction in
NSLog("OK is Pressed. Proceeding...")
}
//Adding actions
alert.addAction(okAction)
//Display alert
self.presentViewController(alert, animated: true, completion: nil)
}
}
I am trying to accomplish whole custom view thing from a xib file and it is related to CustomCameraView class. I set up two delegate methods to the CustomCameraView in able to use those but these are not necessary for this question so I am not gonna post the code but still I think you might need to know. What is related to the question is the xib file, so please find it below:
The buttons are showing up at where they supposed to be however I cant make use of that imageView. I created an image view here so that I can take its frame.size and set to the picker's frame.size (you can see this in my code listing). And of coruse the reference to that image view is in CustomCameraView class, so I am reaching from that class as you might notice also.
I have been trying for a whole day honestly yet I could not find a solution for that either or myself on net. I have read AVFoundation also but seems like there is not a clear explanation of how to set the frame size of that view in AVFoundation documentations as in UIImagePicker so I just decided to ask you guys as I am so lost in the project and cannot think another way right now.
I would be really appreciate if you can help me. Let me know if you need further information.
Thanks!