iOS 6社交框架不会设置或没有警报 [英] iOS 6 Social framework not going to settings or no alert

查看:106
本文介绍了iOS 6社交框架不会设置或没有警报的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在iOS6中实现新的社交框架,并且让它工作,除了两个奇怪的问题。如果我启用了我感兴趣的服务(说... FaceBook),那么它的工作正常。但是,如果帐户从设置面板中删除(让我们说FaceBook要保持一致),那么我会在模拟器和设备中获得不同的,令人沮丧的行为。

I'm trying to implement the new social framework in iOS6, and have it working, except for 2 weird problems. If I've enabled the services I'm interested in (say... FaceBook), then it works fine. However, if the accounts are deleted from the settings panel (let's say FaceBook, to be consistent), then I get differing, and frustrating behaviors in the simulator and the device.

以下是我的视图控制器中的相关代码:

Here's the relevant code in my view controller:

//Method for FaceBook

- (IBAction)doFacebook:(id)sender{
//check to see if facebook account exists
if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook]) {

    // Create the view controller defined in the .h file

    fb=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    // make the default string
    NSString *FBString= [NSString
                         stringWithFormat:@"%@\r via #GibberishGenerator", gibText.text];
    [fb setInitialText:FBString];
    // show the controller
    [self presentViewController:fb animated:YES completion:nil];

    }
}

这是启动时的奇怪行为关闭上述方法:

And here's the weird behavior when firing off the above method:

模拟器(版本6.0(358.4 ))中,我得到对话框,通知我,我还没有设置任何在设置和取消按钮的脸书帐户中,点击设置即可关闭对话框,但不会将我转到设置面板。

In the simulator (version 6.0 (358.4) I get the dialog informing me that I haven't set up any faceBook accounts with "Settings" and "Cancel" buttons. Hitting "Settings" just dismisses the dialog, but doesn't take me to the settings panel.

强力> iPhone 4s运行6.01,触发触发方法的按钮不会产生任何结果,换句话说,我没有对话框通知我必须设置一个FaceBook帐户。

On my iPhone 4s running 6.01, hitting the button that triggers the method results in... nothing. In other words, I get no dialog informing me that I have to set up a FaceBook account.

提前感谢您的帮助。

这是我的新实现,基于user1734802的有用评论。

Here's my new implementation, based on user1734802's helpful comment.

//Method for FaceBook

- (IBAction)doFacebook:(id)sender{

    // Create the view controller defined in the .h file

    fb=[SLComposeViewController composeViewControllerForServiceType:SLServiceTypeFacebook];

    // make the default string
    NSString *FBString= [NSString
                         stringWithFormat:@"%@\r via #GibberishGenerator", gibText.text];
    [fb setInitialText:FBString];
    // show the controller
    [self presentViewController:fb animated:YES completion:nil];

      }

在某些时候,我希望

 [SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])

实际工作正常(触发自动对话框,并带您进入设置),所以我实际上只是在我的代码中进行了评论。

to actually work correctly (triggering the automatic dialog, and taking you to settings), so I actually just commented it out in my code.

推荐答案

我有同样的问题,我通过删除If语句修复它:

I had the same problem, i fixed it by removing the If statement:

if ([SLComposeViewController isAvailableForServiceType:SLServiceTypeFacebook])

然后视图将显示,尽管在设置中没有配置Facebook / Twitter帐户。
和没有Facebook / Twitter帐户alertView显示!我能够点击警报上的设置按钮,并指示我进行设置(在设置中配置Facebook / Twitter帐户)

Then the view will display although there is no Facebook/Twitter account configured in the settings. And the "No Facebook/Twitter accounts" alertView showed! And I was able to hit the "Settings" button on the alert, and it directed me to the settings (Configure Facebook/Twitter account in the settings)

这是我使用的代码,它对我来说完美:

This is the code I used, and it works perfectly for me:

- (IBAction)bTwitter:(id)sender {

mySLComposerSheet = [[SLComposeViewController alloc] init];

mySLComposerSheet = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter];

[mySLComposerSheet setInitialText:@""];

[mySLComposerSheet addImage:[UIImage imageNamed:@""]];

[self presentViewController:mySLComposerSheet animated:YES completion:nil];

}

这篇关于iOS 6社交框架不会设置或没有警报的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆