Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

IOS 5 Cancel Button #254

dubfire opened this Issue Jun 20, 2011 · 32 comments


None yet

dubfire commented Jun 20, 2011

In ios 5 not working Cancel Button from views when load twitter view!

Any idea?!?!?!

Sorry for my english!

rramnel commented Jun 21, 2011


I have the same issue as well. The cancel button does not work when authorizing for twitter using oAuth.

raspu commented Jun 23, 2011

Yes, same here...

hdoria commented Jun 23, 2011

Same problem. Sugestions?

Hey everyone,

I've fixed the issue but due to iOS5 being under NDA I'm unable to push out my fix. I will update my fork with the fix once the NDA for 5.0 is lifted though.


btedev commented Jul 11, 2011

This link helped me fix it pretty easily (in SHK.m). I'm OK with posting it because you'd have to be under the NDA to read it anyway: https://devforums.apple.com/message/451045

Same problem.

Could you say more btedev ?

btedev commented Jul 13, 2011

I don't want to upset the NDA police but I'll be glad to discuss privately. Just message me directly through my GitHub profile.

When editing the SHK.m and applying the accepted answer code on https://devforums.apple.com/message/451045 the problem is solved. Thx.

aslocal commented Oct 11, 2011

What was the solution to this? I looked through the code above, but I wasn't able to get the button to work again.


btedev commented Oct 12, 2011

Now that the NDA is lifted, I just changed the two instances of [[currentView parentViewController] dismissModalViewControllerAnimated:YES] in SHK.m to [currentView dismissModalViewControllerAnimated:YES].

This gist is my SHK.m: https://gist.github.com/1281191

aslocal commented Oct 12, 2011

Great, I appreciate it.


ghost commented Oct 16, 2011

Great, works perfect for iOS5, but now I'm getting an EXC_BAD_ACCESS crash on iOS 4:

Debugger points to: [currentView dismissModalViewControllerAnimated:animated];

This needs to have detection on whether it's IOS5 or not to check whether it should be [[currentView parentViewController] dismissModalViewControllerAnimated:YES] or [currentView dismissModalViewControllerAnimated:YES] because it's probably not liking the reference.


ghost commented Oct 16, 2011

After more testing, it appears that this crash only happens in the iOS 4.3 simulator. It works fine on an iPhone 4 running iOS 4.3. Strange.

hdoria commented Oct 16, 2011

Here's what i did:

if ([currentView respondsToSelector:@selector(presentingViewController)])
[[currentView presentingViewController] dismissViewControllerAnimated:YES completion:NO];
[[currentView parentViewController] dismissModalViewControllerAnimated:YES];

gil commented Oct 25, 2011

@corvino 's fix is working perfectly here. Thanks!! ;)

scurioni commented Nov 2, 2011

Working here too. Thanks a lot!

gonzooin commented Nov 7, 2011

Working great !
Thank you !

Thanks @corvino for the patch!

it works perfect, thank you!!!

@gradha gradha pushed a commit to gradha/ShareKit that referenced this issue Nov 23, 2011

Nathan Corvino + Grzegorz Adam Hankiewicz Fix issue #254 - IOS 5 Cancel Button. 30277da

Thank you so much!

Here's what I did for having it runnable on ios5 and ios4.
// Dismiss the modal view
if ([currentView parentViewController] != nil)
self.isDismissingView = YES;
[[currentView parentViewController] dismissModalViewControllerAnimated:animated];
else if([currentView respondsToSelector:@selector(presentingViewController)])
self.isDismissingView = YES;
[[currentView presentingViewController] dismissModalViewControllerAnimated:animated];
self.currentView = nil;

also, because the delegate doesn't work for static functions, I modified those two functions to be(SHKActionSheet.xx) :

  • (SHKActionSheet *)actionSheetForType:(SHKShareType)type;
  • (SHKActionSheet *)actionSheetForItem:(SHKItem *)i;


Prior to iOS 5.0, if a view did not have a parent view controller and was being presented modally, the view controller that was presenting it would be returned. This is no longer the case. Use the presentingViewController property to access the presenting view controller.

I'm replace parentViewController with presentingViewController and all will be ok

headkit commented Feb 26, 2012

thnx Magnat12 - replacing parentViewController with presentingViewController works in my case!

still not working for me in iOS5.1 (using ARC w/ -fno-objc-arc)

It looks like CurrentView in SHK isn't getting set correctly

to all: better way now is use new version of ShareKit: https://github.com/ShareKit/ShareKit
Where added iOS5 support, Twitter framework in iOS5 and many other improvements and bug fixed

Thanks @btedev It works

@corvino Thank you very much! Works perfectly!

akdoshi commented Sep 19, 2012

having same issue as mclark4386 ... ? any updates ?

akdoshi commented Sep 19, 2012

i have debug and found the issue you need to add this code in SHK.m file in hideCurrentViewControllerAnimated function line no 183

if ([currentView parentViewController] != nil)
self.isDismissingView = YES;
[currentView dismissModalViewControllerAnimated:YES];
//[[currentView parentViewController] dismissModalViewControllerAnimated:animated];

        [currentView dismissModalViewControllerAnimated:YES];
        self.currentView = nil;

I have added just one line in else part previously it was just
self.currentView = nil;

teoco commented Sep 21, 2012

@corvino: thank you a lot.

thanks for all of you..
I hope I can serve all of you some time..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment