DKImagePickerController
DKImagePickerController copied to clipboard
check_background is nil
ios 11.0.1 iphone 8 (simulator)
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCache setObject:forKey:cost:]: attempt to insert nil value (key: checked_background)'
*** First throw call stack:
(
0 CoreFoundation 0x000000010ea011cb __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010cfa6f41 objc_exception_throw + 48
2 CoreFoundation 0x000000010e96b0cb -[NSCache setObject:forKey:cost:] + 379
3 DKImagePickerController 0x000000010710df67 $S23DKImagePickerController0abC8ResourceC08imageForD0_11stretchable9cacheableSo7UIImageCSS_S2btFZ + 1127
4 DKImagePickerController 0x000000010710d711 $S23DKImagePickerController0abC8ResourceC12checkedImageSo7UIImageCyFZ + 97
5 DKImagePickerController 0x0000000107097218 $S23DKImagePickerController27DKAssetGroupDetailImageCellC0A9CheckViewC05checkgJ0So07UIImageJ0CvgAHyXEfU_ + 56
6 DKImagePickerController 0x000000010709713e $S23DKImagePickerController27DKAssetGroupDetailImageCellC0A9CheckViewC05checkgJ0So07UIImageJ0Cvg + 318
7 DKImagePickerController 0x0000000107097937 $S23DKImagePickerController27DKAssetGroupDetailImageCellC0A9CheckViewC5frameAESo6CGRectV_tcfc + 487
8 DKImagePickerController 0x0000000107097a06 $S23DKImagePickerController27DKAssetGroupDetailImageCellC0A9CheckViewC5frameAESo6CGRectV_tcfcTo + 38
9 UIKit 0x000000010a29317e -[UIView init] + 62
10 DKImagePickerController 0x0000000107098e53 $SSo6UIViewCABycfcTO + 19
11 DKImagePickerController 0x00000001070989ef $SSo6UIViewCABycfC + 31
12 DKImagePickerController 0x00000001070964e2 $S23DKImagePickerController27DKAssetGroupDetailImageCellC5frameACSo6CGRectV_tcfc + 210
13 DKImagePickerController 0x0000000107096e56 $S23DKImagePickerController27DKAssetGroupDetailImageCellC5frameACSo6CGRectV_tcfcTo + 38
14 UIKit 0x000000010acd5284 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 1551
15 UIKit 0x000000010acd58cb -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169
16 DKImagePickerController 0x00000001070a757d $S23DKImagePickerController20DKAssetGroupDetailVCC19dequeueReusableCell3forAA0def4BaseJ0C10Foundation9IndexPathV_tF + 1853
17 DKImagePickerController 0x00000001070a8aff $S23DKImagePickerController20DKAssetGroupDetailVCC14collectionView_13cellForItemAtSo012UICollectionI4CellCSo0nI0C_10Foundation9IndexPathVtF + 223
18 DKImagePickerController 0x00000001070a8e5c $S23DKImagePickerController20DKAssetGroupDetailVCC14collectionView_13cellForItemAtSo012UICollectionI4CellCSo0nI0C_10Foundation9IndexPathVtFTo + 108
19 UIKit 0x000000010acbeb1a -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:] + 290
20 UIKit 0x000000010acbe9f2 -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 35
21 UIKit 0x000000010acc3f0f -[UICollectionView _updateVisibleCellsNow:] + 4775
22 UIKit 0x000000010acc9e04 -[UICollectionView layoutSubviews] + 364
23 UIKit 0x000000010a2c74f1 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1439
24 QuartzCore 0x00000001095dc49a -[CALayer layoutSublayers] + 153
25 QuartzCore 0x00000001095e0589 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 401
26 QuartzCore 0x00000001095690fd _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 365
27 QuartzCore 0x0000000109594a14 _ZN2CA11Transaction6commitEv + 500
28 QuartzCore 0x0000000109595760 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 76
29 CoreFoundation 0x000000010e9a3db7 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
30 CoreFoundation 0x000000010e9a3d0e __CFRunLoopDoObservers + 430
31 CoreFoundation 0x000000010e988324 __CFRunLoopRun + 1572
32 CoreFoundation 0x000000010e987a89 CFRunLoopRunSpecific + 409
33 GraphicsServices 0x00000001128c49c6 GSEventRunModal + 62
34 UIKit 0x000000010a1f623c UIApplicationMain + 159
35 taling 0x0000000102e23087 main + 71
36 libdyld.dylib 0x000000010fd65d81 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
image is nil..
public class func imageForResource(_ name: String, stretchable: Bool = false, cacheable: Bool = false) -> UIImage {
if let image = customImageBlock?(name) {
return image
}
if cacheable {
if let cache = self.cache.object(forKey: name as NSString) {
return cache
}
}
let bundle = Bundle.imagePickerControllerBundle()
var image = UIImage(named: name, in: bundle, compatibleWith: nil) ?? UIImage()
if stretchable {
image = self.stretchImgFromMiddle(image)
}
if cacheable {
self.cache.setObject(image, forKey: name as NSString)
}
return image
}
Please Help me.-
Hi @choiks14 Are you using Carthage or Cocoapods?
@zhangao0086 cocoapods version 4.0.4
pod 'DKImagePickerController', :git => 'https://github.com/zhangao0086/DKImagePickerController', :tag => '4.0.4'
@zhangao0086 can you tell me solution please
@choiks14 Are you using Swift 4.2 or Swift 4.1?
For Swift 4.2, please update to the latest version 4.1.0:
pod 'DKImagePickerController'
For Swift 4.1
pod 'DKImagePickerController', :git => 'https://github.com/zhangao0086/DKImagePickerController.git', :branch => 'Swift4'
I think they will work fine :)
@zhangao0086 no it's not working
please try ios 11.0
@zhangao0086 i'm using swift 4.2
pod 'DKImagePickerController'
not working
public class func imageForResource(_ name: String, stretchable: Bool = false, cacheable: Bool = false) -> UIImage {
if let image = customImageBlock?(name) {
return image
}
if cacheable {
if let cache = self.cache.object(forKey: name as NSString) {
return cache
}
}
//bundle is ok
let bundle = Bundle.imagePickerControllerBundle()
//image return zero image(width:0,height:0)
var image = UIImage(named: name, in: bundle, compatibleWith: nil) ?? UIImage()
if stretchable {
//so stretchImgFromMiddle method fire exception
//got nil image
image = self.stretchImgFromMiddle(image)
}
if cacheable {
self.cache.setObject(image, forKey: name as NSString)
}
return image
}
please read this code
please help me...
I cannot reproduce it... Could you make a mini project that can reproduce this issue..? And could you check your Podfile.lock
file what version used?
@zhangao0086 yes i'm using 4.1.0 and DKCamera 1.6.4
i'm using
open override var inputAccessoryView: UIView? {
return self.textInputBar
}
I think that is problem..
Hi @choiks14 I don't feel any connection between inputAccessoryView
and this issue.
Have you solved?
same crash here
Fatal Exception: NSInvalidArgumentException
0 CoreFoundation 0x1864a51b8 __exceptionPreprocess
1 libobjc.A.dylib 0x184edc55c objc_exception_throw
2 CoreFoundation 0x1863cc1fc -[NSArray indexOfObjectIdenticalTo:]
3 DKImagePickerController 0x1013e4618 specialized DKImagePickerControllerResourceimageForResource first-element-marker static cacheable(_:_:_:) (<compiler-generated>)
4 DKImagePickerController 0x10139f164 $S23DKImagePickerController27DKAssetGroupDetailImageCellC0A9CheckViewC05checkgJ0So07UIImageJ0Cvg (<compiler-generated>)
5 DKImagePickerController 0x10139f28c DKAssetGroupDetailImageCell.DKImageCheckViewinit(_:) (DKAssetGroupDetailImageCell.swift:55)
6 DKImagePickerController 0x10139f360 @objc DKAssetGroupDetailImageCell.DKImageCheckViewinit(_:) (<compiler-generated>)
7 DKImagePickerController 0x10139ea24 DKAssetGroupDetailImageCellinit(_:) (DKAssetGroupDetailImageCell.swift:97)
8 DKImagePickerController 0x10139f04c @objc DKAssetGroupDetailImageCellinit(_:) (<compiler-generated>)
9 UIKit 0x18cc4fb48 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:]
10 UIKit 0x18c3be0d8 -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:]
11 DKImagePickerController 0x1013a51f4 DKAssetGroupDetailVCfor(_:) (DKAssetGroupDetailVC.swift:394)
12 DKImagePickerController 0x1013ac660 $S23DKImagePickerController20DKAssetGroupDetailVCC14collectionView_13cellForItemAtSo012UICollectionI4CellCSo0nI0C_10Foundation9IndexPathVtFTf4dnn_n (DKAssetGroupDetailVC.swift:446)
13 DKImagePickerController 0x1013a5e34 $S23DKImagePickerController20DKAssetGroupDetailVCC14collectionView_13cellForItemAtSo012UICollectionI4CellCSo0nI0C_10Foundation9IndexPathVtFTo (<compiler-generated>)
14 UIKit 0x18cc43c0c -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:notify:]
15 UIKit 0x18c3bbb54 -[UICollectionView _updateVisibleCellsNow:]
16 UIKit 0x18c3b65a8 -[UICollectionView layoutSubviews]
17 UIKit 0x18c357a80 -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
18 QuartzCore 0x1898059d8 -[CALayer layoutSublayers]
19 QuartzCore 0x1897fa4cc CA::Layer::layout_if_needed(CA::Transaction*)
20 QuartzCore 0x1897fa38c CA::Layer::layout_and_display_if_needed(CA::Transaction*)
21 QuartzCore 0x1897773e0 CA::Context::commit_transaction(CA::Transaction*)
22 QuartzCore 0x18979ea68 CA::Transaction::commit()
23 QuartzCore 0x18979f488 CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*)
24 CoreFoundation 0x1864520c0 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
25 CoreFoundation 0x18644fcf0 __CFRunLoopDoObservers
26 CoreFoundation 0x186450180 __CFRunLoopRun
27 CoreFoundation 0x18637e2b8 CFRunLoopRunSpecific
28 GraphicsServices 0x187e32198 GSEventRunModal
29 UIKit 0x18c3c57fc -[UIApplication _run]
30 UIKit 0x18c3c0534 UIApplicationMain
31 syarahswift 0x10002d2c0 main (AppDelegate.swift:55)
32 libdyld.dylib 0x1853615b8 start
pod 'DKImagePickerController', :git => 'https://github.com/zhangao0086/DKImagePickerController', :tag => '4.0.4'
it's worked for me thanks