15

Xcode 4.2(iOS SDK 5)でShareKit 0.2.1を使用してTwitterでテキストを共有しています。 (下記参照)それは罰金共有しますが、モーダルビューコントローラは文句を言わないキャンセルボタンをクリックした後の共有に成功した後に離れて行く:ShareKitモーダルビューコントローラが離さない

enter image description here

そして、これは私のコードです:

-(IBAction)shareOnTwitter:(id)sender{ 


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

    [SHKTwitter shareText:text]; 

} 

何私は間違っている?

答えて

30

私はあなたと同じ問題を抱えています。これはiOS 5の問題です。 ShareKitはUIViewControllerというメソッドをparentViewControllerという名前で使用しており、アップルのドキュメントではこれをiOS 5では使用できなくなるためです。代わりにpresentingViewControllerを使用する必要があります。

ので、ShareKitコードでそれを修正SHK.mに入り、署名(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

+0

これは私が実装した解決策です –

+0

それはデバイスの向きを変更しています – WaaleedKhan

1

これは私が自分のアプリで使っているコードです。 これは問題なく終了します。

NSURL *url = [NSURL URLWithString:@"http://itunes.apple.com/us/app/packager/id459511278?l=nl&ls=1&mt=8"]; 
NSString *twittertext = [[NSString alloc] initWithFormat: @"Tweet Text"]; 
SHKItem *item = [SHKItem URL:url twittertext]; 

// Share the item 
[SHKTwitter shareItem:item]; 
[twittertext release]; 
+0

[NSString stringWithFormat:@ "Tweet Text"]; [twittertext release]を削除します。ライン、それはまだ却下されますか? 明らかに唯一の違いは、私がARCを使用していることです... – cfischer

1

私は私のアプリ(無効ARC)に次のコードを使用している

NSString *text = @"Go away, modal view controller!"; 

[SHKTwitter shareText:text]; 

私はそれがうまく退け確認することができます。 SHKTwitterForm.mの一部のコードをShareTicker ARCと互換性を持たせようとすると、おそらく変更されました。あなたのバグにつながったのは

+0

いいえ、私はARCなしですべてのShareKitファイルをコンパイルしました:-fno-objc-arc – cfischer

+0

私はちょうど元の質問を読み直し、 Xcode 4.3を使用していますか?また、シミュレータのバージョンはどのバグに遭遇しますか?実際のデバイスでもテストしましたか? – Louis

2
if (isDismissingView) 
    return; 

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

    else { 
     //## ADD BELOW ## 
     self.isDismissingView = YES; 
     [currentView dismissModalViewControllerAnimated:animated]; 
     self.currentView = nil; 

    } 
} 
else { 
    [[self getTopViewController].navigationController popViewControllerAnimated:YES]; 
} 
に私の作品
関連する問題