WTweetComposeViewController无法在iP

WTweetComposeViewController无法在iP

本文介绍了TWTweetComposeViewController无法在iPad模拟器上关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用中,我有一个操作表,其按钮之一以模态方式打开TWTweetComposeViewController.在iPhone模拟器上,tweet作曲器上的取消"按钮可以正常工作并关闭视图.但是,在iPad模拟器上,取消"按钮不起作用,并且推文撰写器视图仍保留在屏幕上.甚至更奇怪,因为在按下取消"按钮之后,键盘缩回并且下面的视图变为活动状态.它的行为就好像视图已被关闭,但仍然存在.

In my app I have an action sheet and one of its buttons opens the TWTweetComposeViewController modally. On iPhone simulator the cancel button on the tweet composer works fine and dismisses the view. However, on iPad simulator the cancel button does not work and the tweet composer view remains on the screen. It is even weirder because after pressing the cancel button, the keyboard retracts and the underlying views become active. It behaves as if the view has been dismissed but its is still there.

当用户按下操作按钮时,我使用的代码是:

The code I used when the user pressed the action button is:

-(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];
        }
    }
}

您对如何解决此问题有任何想法吗?或者它是模拟器的错误吗?

Do you have any idea on how to solve this problem or is it a bug of the simulator?

P.S .:我的应用程序是一个标签栏应用程序,该代码是从标签栏的视图控制器之一调用的.

P.S.: My app is a tabbar app and this code is called from one of of the view controller of the tab bar.

推荐答案

我在实际设备上遇到了同样的问题.事实证明,这是Apple SDK TWTweetComposeViewController中的一个错误.

I'm having this same problem on the actual device. It turns out this is a bug in Apple's SDK for TWTweetComposeViewController.

在OpenRadar上查看错误报告: http://openradar.appspot.com/radar?id=1484405.

See the bug report here on OpenRadar: http://openradar.appspot.com/radar?id=1484405.

只是以为我要添加自己的工作方式,即使这没有正确遵循内存准则,这也是一种解决方法:

Just thought I'd add how I'm doing things, even though this is not correctly following memory guidelines, it's a workaround:

[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];
    });

这篇关于TWTweetComposeViewController无法在iPad模拟器上关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 22:00