From e91ffa8c919bac4bc8a9a09dacdb04126a4a16bf Mon Sep 17 00:00:00 2001 From: Jim Kubicek Date: Thu, 2 Feb 2012 16:35:31 -0800 Subject: [PATCH] Dismissal block is now called on any dismissal, not just button-less dismissals --- UIActionSheet+Blocks.h | 3 +-- UIActionSheet+Blocks.m | 7 +++---- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/UIActionSheet+Blocks.h b/UIActionSheet+Blocks.h index 98655d8..bec2c79 100644 --- a/UIActionSheet+Blocks.h +++ b/UIActionSheet+Blocks.h @@ -15,8 +15,7 @@ - (NSInteger)addButtonItem:(RIButtonItem *)item; -/** This block is called when the action sheet is dismssed for any reason other than a button - press. If the user taps outside the view, for example. +/** This block is called when the action sheet is dismssed for any reason. */ @property (copy, nonatomic) RISimpleAction dismissalAction; diff --git a/UIActionSheet+Blocks.m b/UIActionSheet+Blocks.m index d84fb36..6b2fe01 100644 --- a/UIActionSheet+Blocks.m +++ b/UIActionSheet+Blocks.m @@ -89,10 +89,9 @@ - (void)actionSheet:(UIActionSheet *)actionSheet didDismissWithButtonIndex:(NSIn if(item.action) item.action(); } - else if (self.dismissalAction) - { - self.dismissalAction(); - } + + if (self.dismissalAction) self.dismissalAction(); + objc_setAssociatedObject(self, (__bridge const void *)RI_BUTTON_ASS_KEY, nil, OBJC_ASSOCIATION_RETAIN_NONATOMIC); objc_setAssociatedObject(self, (__bridge const void *)RI_DISMISSAL_ACTION_KEY, nil, OBJC_ASSOCIATION_COPY); }