1

I have an UITableview. When a row is selected an UIActionSheet pops up. To add the UIActionSheet I used

[actionSheet showFromRect:cell.bounds inView:cell animated:NO];

Everything works fine, i can select items in the UIActionView, i can tap outside and it disappears. BUT when it disappears (from tapping outside or selecting an item) and i tap fast on something else, e.g. the background, the app crashes with following message:

-[UIActionSheet _dismissForTappedIndex:]: message sent to deallocated instance 0x173796d0

I guess the app weants to dismiss the sheet, but it has been released before? Thank you for any help.

2
  • Are you building for iOS8, using Xcode 6? What delegate method are you calling? Are you using clickedButtonAtIndex method for example? Nov 21, 2014 at 15:18
  • Yes I am. I tried willDismissWithButtonIndex and didDismissWithButtonIndex, without success.
    – Sven
    Nov 21, 2014 at 15:57

2 Answers 2

1

Try to keep a reference to the UIActionSheet. Make it a property for example. This error means that ARC is deallocating the object too fast.IF the error stops happening then thats the problem.

0
0

If you are using the 'clickedButtonAtIndex' delegate method to catch the tap, under iOS8 I experienced crashing too, though it was fixed when changed to didDismissButtonAtIndex.

I had a similar crash with UIAlertView so this may also be the case with UIActionSheet.

Under iOS8, please change your delegate method clickedButtonAtIndex to didDismissWithButtonIndex

change this line to

 - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

with this

 - (void)actionSheet:(UIActionSheet *)actionSheet willDismissWithButtonIndex (NSInteger)buttonIndex {

You should find this will solve the crash.

I hope this helps.

3
  • The question is about UIActionSheet, not UIAlertView.
    – rmaddy
    Nov 21, 2014 at 15:26
  • @rmaddy Sorry, my mistake, read too quickly. I'll check this and update answer Nov 21, 2014 at 15:27
  • Thank you but neither willDismissWithButtonIndex nor didDismissWithButtonIndex are successful :-(.
    – Sven
    Nov 21, 2014 at 15:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.