Search code examples
iphoneiossharekit

After updating to iOS 6 all of the Cancel buttons are not working in sharekit


- (void)cancel
{   
[[SHK currentHelper] hideCurrentViewControllerAnimated:YES];
}

Above given is the code for cancel button on sharekit twitter form but it is not working. I believe it was working before updating to iOS 6. After updating to iOS 6 i replaced deprecated ones.

- (void)hideCurrentViewControllerAnimated:(BOOL)animated
{
if (isDismissingView)
    return;

if (currentView != nil)
{
    // Dismiss the modal view
    if ([currentView parentViewController] != nil)
    {
        self.isDismissingView = YES;
        [[currentView parentViewController] dismissViewControllerAnimated:YES completion:nil];
    }

    else
        self.currentView = nil;
}
}

I replaced dismissModalViewControllerAnimated:YES with dismissViewControllerAnimated:YES completion:nil.

Now i noticed cancel button is not working in any of the form pinboardform, SHKShareMenu, Instapaper and in all others .

Anyone knows why after updating to iOS 6 this cancel button on Sharekit stopped working. On clicking the cancel button nothing happens.

Why is that. What is the reason.

Any ideas.

Thanks


Solution

  • Fixed it. It has to presentingViewController instead of parentViewController.

    Below is the code

    - (void)hideCurrentViewControllerAnimated:(BOOL)animated
    {
    if (isDismissingView)
        return;
    
    if (currentView != nil)
    {
        // Dismiss the modal view
        if ([currentView presentingViewController] != nil)
        {
            self.isDismissingView = YES;
            [[currentView presentingViewController] dismissViewControllerAnimated:YES completion:nil];
        }
    
        else
            self.currentView = nil;
    }
    }
    

    This change of code in SHK.m made all cancels working. Now all cancels are working in Sharekit.