AliSoftware / OHActionSheet

UIActionSheet subclass that uses blocks to handle its callback (which make the code much more easier and readable)
MIT License
27 stars 5 forks source link

Crash on iOS8 #5

Open cujo30227 opened 10 years ago

cujo30227 commented 10 years ago

Hi, OHActionSheet crashes on iOS8 beta 1 when trying to present an action sheet with the showInView method on an iPad. Here's the crash log:

*\ Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Application tried to present modally an active controller <_UIAlertShimPresentingViewController: 0x189675d0>.'

Last Exception Backtrace: 0 CoreFoundation 0x2a7562bf CFDateGetTimeIntervalSinceDate + 16011 1 libobjc.A.dylib 0x37672d2f _objc_exception_throw + 39 2 UIKit 0x2e01c89d _UINavigationButtonUpdateAccessibilityBackgroundsForBlendMode + 158342 3 UIKit 0x2de178b1 UIRectIntegralWithScale + 1298 4 UIKit 0x2e3c09ad _UIKitSafeTextView + 49310 5 UIKit 0x2e3bffa5 _UIKitSafeTextView + 46742 6 XXXXX 0x0012765d -OHActionSheet showInView: 7 XXXXX 0x0012736f +OHActionSheet showSheetInView:title:cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:completion: 8 XXXXX 0x000cbad9 -MainViewController shareMusic:

AliSoftware commented 10 years ago

Thanks for the crash report.

I didn't manage to reproduce it even on Xcode6-Beta 1 on iOS8 Simulator. But I released a version 2.0.0 of OHActionSheet anyway, with the new API requiring now to pass the view FROM which you want your actionsheet to be displayed from, like the UIBarButtonItem from which the popover should appear or whatnot. Feel free to try it and keep me posted if you manage to reproduce the issue (with a full example so I can reproduce it myself if possible).


Note that there still seem to be some issues with Xcode ß1 (I'm downloading ß2 right now to check if they are still present) like the following, from which I can't do anything and for which we should file a bugreport to Apple as they seem to be bugs from Apple (that seems to be present even with a standard UIActionSheet). See the updated Example project from the OHActionSheet repository.

zcharter commented 10 years ago

I have only been reproduce this issue with:

Relevant links (with full instructions to reproduce with UIActionSheet):

AliSoftware commented 10 years ago

Thx @zcharter for your feedback.

Won't be investigating this on OHActionSheet until Apple's own bug on UIActionSheet is fixed then.

vinthewrench commented 10 years ago

I am seeing the same issues on iPad using Xcode 6 beta 7.

I believe Apple changed internal implementation of UIActionSheet

its possible that we can't use this class any longer with IOS 8

Subclassing Notes UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more customization than provided by the UIActionSheet API, you can create your own and present it modally with presentViewController:animated:completion:.

AliSoftware commented 10 years ago

Thanks for the feedback.

But actually when I ran the tests myself, the crash occurred both when using my OHActionSheet and Apple's own UIActionSheet in the same conditions. @zcharter 's comment and links to the Apple forum threads seems to confirm that.

Did you manage to create some code that crash in Xcode6ß7 only when using OHActionSheet but does not crash when replacing OHActionSheet by UIActionSheet? If so, I'm strongly interested in the code snippet or sample project.


(Note: btw I believe this suclassing note was already present in the doc before SDK8 and was to prevent people to subclass OHActionSheet in order to customize its appearance. OHActionSheet does not subclass UIActionSheet to mess up with its internal subviews or whatnot, but simply to wrap calls to its delegate methods into a block API, so I believe there is no reason that it would have any impact, contrary to when subclassing to mess with the internal implementation and internal subviews like other do… But if you manage to have an example that crash with OHActionSheet and not with UIActionSheet maybe I'll try refactoring OHActionSheet to use a composition pattern instead of inheritence to work around this anyway)

abournier commented 10 years ago

On the final release of iOS 8 GM and Xcode 6, I have no crash but the ActionSheet doesn't appear on iPad (nothing happens when the code is executed). Note that it works on iPhone !

suculent commented 10 years ago

I have the same issue and it happens completely inside iOS (8 GM) in UIKit: _UINavigationButtonUpdateAccessibilityBackgroundsForBlendMode calls CFArrayGetFirstIndexOfValue< then CFDateGetTimeIntervalSinceDate and that throws the NSRangeException; seems like caused by some of recent changes in CFCalendar.

AliSoftware commented 10 years ago

Wow WTF does CFCalendar would have to do with this?! I'll definitely have to check this. Thanks for the feedback guys.

I hope I'll have time to investigate this issue this weekend, seems like UIActionSheet has some pretty serious changes un iOS8.


Note that UIActionSheet and UIAlertView are now deprecated in iOS8 in favor of UIAlertController. I've not yet decided if I'll refactor OHActionSheet and OHAlertView use UIAlertController internally when the user is running on iOS8 (and keep using UIAlertView/UIActionSheet when iOS7) to help people make the transition, or just keep them as is and let users abandon OHActionSheet and OHAlertView directly in favor of UIAlertController themselves. For your own code, you may thus consider using UIAlertController directly if ([UIAlertController class]) is true (and keep using OHActionSheet if it's false)

Of course this remark doesn't affect the fact that I'll try and fix the issues for existing code, so that OHActionSheet and OHAlertView will keep working on iOS8

AliSoftware commented 10 years ago

Just to let you know that I didn't forget about you guys but I'm sorry to tell that I won't have a minute until sunday to get started on this. Sorry for the delay.

Don't hesitate to investigate and let me know if you find any useful Intel about this anyway.

AliSoftware commented 10 years ago

Hi guys,

Would it be ok for you if I transform the OHActionSheet from a subclass of UIActionSheet to a subclass of NSObject, that will still have the same API as now, but so that when used on iOS7 or below it will then use an UIActionSheet internally, and when used on iOS8 it would use UIAlertController instead?

I'm guessing subclassing UIActionSheet probably messes it up in iOS8 now, so this would be a nice workaround.

zcharter commented 10 years ago

That seems like a reasonable approach to me.