I ran into a serious problem with UIImagePickerController in fast mode. After continuously capturing 50-60 images, the application crashed without registering any problems in the tricks. This is a memory problem. I tried the following solution.
@interface UIImagePickerController (Singleton) +(UIImagePickerController *) instance; @end @implementation UIImagePickerController (Singleton) +(UIImagePickerController *) instance{ static UIImagePickerController *_instance; static dispatch_once_t onceToken; dispatch_once(&onceToken,^{ _instance=[[UIImagePickerController alloc] init]; }); return _instance } if UIImagePickerController.isSourceTypeAvailable(UIImagePickerControllerSourceType.Camera){ let image = UIImagePickerController.instance()
Any idea what's wrong here? Your help will be greatly appreciated. Thanks
class func resizeAndCompress(image: UIImage!) -> UIImage? { let size = image.size let maxLength: CGFloat = 640.0 var newSize: CGSize if size.width > size.height { let scale = maxLength / size.width newSize = CGSizeMake(maxLength, size.height * scale) } else { let scale = maxLength / size.height newSize = CGSizeMake(size.width * scale, maxLength) }
Crash Solution It seems the problem is with the iOS version. I created my custom image control using AVVideoCapture. Now I can capture over 1000 images.
source share