2

I am using applozic chat sdk for ios and sending images , video successfully . My requirement is to change camera overlay. When I try to add overlay on camera it crashes.

 let camaraObj : ALImagePickerController = ALImagePickerController()

 let overlay =UIView(frame: UIScreen.mainScreen().bounds)
 overlay.backgroundColor = UIColor.redColor()     
 camaraObj.cameraOverlayView = overlay

Crash log: libc++abi.dylib: terminating with uncaught exception of type NSException.

Any help ?

vaibhav
  • 4,038
  • 1
  • 21
  • 51

1 Answers1

2

Looks like you are not setting the sourceType. ALImagePickerController is used for sending pictures from photos only. You need to explicitly set source type if you want to use it for camera.

i.e. self.mImagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;

We just tried the same and got below exception:

2017-01-30 14:30:30.954540 applozicdemo[3106:1925853] Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Source type must be UIImagePickerControllerSourceTypeCamera' First throw call stack: (0x1819de1c0 0x18041855c 0x187a945cc 0x187d23294 0x1003f9dcc 0x10016525c 0x10016521c 0x10016a284 0x18198bf2c 0x181989b18 0x1818b8048 0x18333e198 0x1878a42fc 0x18789f034 0x1000517b8 0x18089c5b8) libc++abi.dylib: terminating with uncaught exception of type NSException

Adarsh
  • 411
  • 5
  • 9
  • Hi adarsh , we tried this but overlay is not showing when we open camera in chat attachment. But yes it ignore crash. We are still trying to add overlay on camera. – Chanchal Warde Jan 30 '17 at 09:55
  • Can you please try with frame from picker-view itself? – Adarsh Jan 30 '17 at 10:08
  • Can you please suggest code and where to add this code. As we are adding this in AppDelegate when application launching. – Chanchal Warde Jan 30 '17 at 10:25
  • You can use something like : let camaraObj : ALImagePickerController = ALImagePickerController() let overlay = UIView(frame: camaraObj.view.frame) camaraObj.sourceType = UIImagePickerControllerSourceType.camera overlay.backgroundColor = UIColor.red; camaraObj.cameraOverlayView = overlay; self.present(camaraObj, animated:true, completion: nil) – Adarsh Jan 30 '17 at 11:59
  • 1
    Got the updatable code from [here](https://www.applozic.com/blog/add-applozic-chat-framework-ios/) . Now i can customize as per my requirements. –  Feb 02 '17 at 06:50