2012-03-14 3 views
0

私のアプリケーションでは、アクションシートがあり、そのボタンの1つがTWTweetComposeViewControllerをモーダルで開きます。 iPhoneのシミュレータでは、ツイート作曲家のキャンセルボタンがうまく動作し、表示が消えます。しかし、iPadのシミュレータでは、キャンセルボタンは機能せず、ツイート作曲家のビューは画面上に残ります。キャンセルボタンを押すと、キーボードが後退し、下にあるビューがアクティブになるため、さらに奇妙です。ビューが終了したように動作しますが、ビューはまだそこにあります。TWTweetComposeViewControllerはiPadシミュレータで解散しません

ユーザーがアクションボタンが押されたときに、私が使用したコード:

-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex 
{ 
    NSString *buttonTitle = [actionSheet buttonTitleAtIndex:buttonIndex]; 
    if ([buttonTitle isEqualToString:@"Open in Safari"]){ 
     [[UIApplication sharedApplication] openURL:[self.webView.request URL]]; 
    }else if ([buttonTitle isEqualToString:@"Twitter"]){ 
     if ([TWTweetComposeViewController canSendTweet]){ 
      TWTweetComposeViewController *tweetSheet = [[TWTweetComposeViewController alloc] init]; 
      [tweetSheet addURL:[self.webView.request URL]]; 
      tweetSheet.completionHandler = ^(TWTweetComposeViewControllerResult result){ 
       if (result == TWTweetComposeViewControllerResultCancelled){ 
        [self dismissModalViewControllerAnimated:YES]; 
       } 
      }; 
      [self presentModalViewController:tweetSheet animated:YES]; 
     }else { 
      UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Twitter error" message:@"You can't send a tweet right now, make sure your device has an internet connection and you have at least one Twitter account setup" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil]; 
      [alertView show]; 
     } 
    } 
} 

あなたがこの問題を解決する方法上の任意のアイデアを持っていますか、それは、シミュレータのバグですか?

P .:私のアプリはタブバーアプリケーションであり、このコードはタブバーのビューコントローラの1つから呼び出されます。

+0

最新バージョンにXcodeとiOSのSDKを更新した後、 、それは現在正常に動作しています。 – Luiz

答えて

5

実際のデバイスで同じ問題が発生しています。これはAppleのSDKのTWTweetComposeViewControllerのバグです。

OpenRadarのバグ報告は、http://openradar.appspot.com/radar?id=1484405をご覧ください。つぶやき作曲するための図では、そのキャンセルまたは ボタンを送信して、それ自体を閉じるにもかかわらず、[のUIViewController dismissModalViewControllerAnimated] -

completionHandlerブロックは TWTweetComposeViewControllerに追加されると、完了ハンドラが を呼び出す必要があります。そうしないと、タッチイベントは、ツイート作曲家を生み出した ビューに到達しません。

ただ、これは正しくメモリガイドラインに従っていない、それは回避策だにもかかわらず、私は物事をやっている方法を追加しようと思いました:

[compose setCompletionHandler:^(TWTweetComposeViewControllerResult result){ 

    dispatch_async(dispatch_get_main_queue(), ^{ 

     if(self.delegate != nil) 
     { 
      if (result == TWTweetComposeViewControllerResultDone) 
      { 
       [self.delegate twitterOperation:TETwitterOperationTweet 
          completedSuccessfully:YES 
          withResponseString:@"Tweet Successful"]; 
      } 
      else if(result == TWTweetComposeViewControllerResultCancelled) 
      { 
       [self.delegate twitterOperation:TETwitterOperationTweet 
          completedSuccessfully:NO 
          withResponseString:@"Tweet Cancelled"]; 
      } 
     } 

     // Dismiss per Apple's Twitter example 
     [self.shownInViewController dismissViewControllerAnimated:YES 
                 completion:nil]; 

     // Yuck. But it's necessary. 
     [compose release]; 
    }); 
+0

XcodeおよびiOS SDKを最新バージョンにアップデートした後、正常に動作しています。ご協力いただきありがとうございます。 – Luiz

+0

これはiOS 6.1以降ではまだ必要です。 'dismissModalViewControllerAnimatedなし:' 'TWTweetComposeViewController'を閉じるには、Cancelをもう一度押す必要があります。 –

+0

@OrtwinGentz以来、私は 'TWTweetComposeViewController'を使用して放棄しました.iOS 6.0以降では廃止予定です。代わりに私は新しいソーシャルフレームワークを使用しています:https://developer.apple.com/library/ios/#documentation/Social/Reference/Social_Framework/_index.html – Maurizio

関連する問題