guillermomuntaner/GMImagePicker

iOS 10 Crash in GMImagePickerController

Opened this issue ยท 6 comments

sfrdx commented
Specific Details

GMImagePicker is crashing in the most recent version of iOS 10 beta version (beta 3). It is crashing on this line:

[(UIView*)[_navigationController.toolbar.subviews objectAtIndex:0] setAlpha:0.75f]; // URGH - I know!

https://github.com/guillermomuntaner/GMImagePicker/blob/master/GMImagePicker/GMImagePickerController.m#L89

with the error:

GMPhotoPicker[2127:611046] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArray0 objectAtIndex:]: index 0 beyond bounds for empty NSArray'

and indeed if you stop there you find that _navicationController.toolbar.subviews is indeed an empty array.


Xcode Build

Xcode 8 Beta 2

iOS

10.0 Beta 3 (14A5309d)

sfrdx commented

Additional thoughts: it appears this line of code is attempting to duplicate the transparency effect but with a tint option that is slightly different than Apple's method.

Thoughts about removing this line of code and fixing the transparency to be similar to Apple's?

It will change it so that the navigationBar will need a BarTintColor to make it solid, otherwise it will be the same as Apple's background color where the color is faded based on the transparency light/dark on top of it.
This might not be the result users expect but it is closer to what Apple does and there still would be an option to have a solid color as they are getting now.

I do want to note that transparency is currently not working for me on iOS 9.3. All I see is a solid white nav bar if I don't change any custom preferences and a weird ability to see the collection view over top of the status bar. I had to set transparency to NO in my own app to prevent that from happening.
Also I unfortunately don't have any iOS 8 devices left to test on since we dropped iOS 8 so I cannot comment on iOS8 behavior.

sfrdx commented

Currently working on this in our own fork now.

[(UIView*)[_navigationController.toolbar.subviews objectAtIndex:0] setAlpha:0.75f]; // URGH - I know!
crash on

I just comment that line, and it works like a charm!
//[(UIView*)[_navigationController.toolbar.subviews objectAtIndex:0] setAlpha:0.75f]; // URGH - I know!

It is always recommended to use firstObject instead of [... objectAtIndex:0].
firstObject returns nil when array is empty instead of crashing app.