我在xcode 4.2(ios sdk 5)上使用sharekit 0.2.1在twitter上共享文本。它共享很好,但在单击“取消”按钮后,模式视图控制器在成功共享后不会消失(请参见下文):
这是我的密码:

-(IBAction)shareOnTwitter:(id)sender{


    // Item to share
    NSString *text = @"Go away, modal view controller!";

    [SHKTwitter shareText:text];

}

我做错什么了?

最佳答案

我和你有同样的问题。这是一个iOS5版本。这是因为sharekit在UIViewController上使用了一个名为parentViewController的方法,根据apple文档,在ios 5中你不能再使用这个方法。相反,您必须使用presentingViewController
因此,要在sharekit代码中修复它,请进入shk.m,找到带有signature(void)hideCurrentViewControllerAnimated:(BOOL)animated的方法,并将其替换为:

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

    if (currentView != nil)
    {
        // Dismiss the modal view
        if ([currentView parentViewController] != nil)
        {
            self.isDismissingView = YES;
            [[currentView parentViewController] dismissModalViewControllerAnimated:animated];
        } else if ([currentView presentingViewController] != nil) {
            self.isDismissingView = YES;
            [[currentView presentingViewController] dismissModalViewControllerAnimated:animated];
    } else
        self.currentView = nil;
    }
}

这在ios 5上对我很有用。

10-07 19:39