尝试在iOS应用程序

时间:2016-10-17 17:43:29

标签: ios swift xcode facebook

我在尝试运行我的第一个社交网络计划时遇到问题。我一直在关注Swift 3的Mark Price iOS编程指南,当我尝试登录FB时出现了我的问题。当我登录屏幕变为白色,然后在我的错误对话框中显示:

2016-10-17 13:35:16.744 sinogrecosocialnetwork [31605:]应用程序的实现:openURL:sourceApplication:annotation:not found。请将处理程序添加到App Delegate中。分类:sinogrecosocialnetwork.AppDelegate

我并不完全确定这意味着什么。我试过重写教程给我看的所有东西,但是我迷路了。我该怎么做才能解决这个问题?

谢谢。

1 个答案:

答案 0 :(得分:0)

您的应用程序明确表示您尚未实现应用程序:openURL:sourceApplication:annotation :,在app delegate中实现以下方法(确保您还在info.plist中添加了所需的密钥,请参阅https://developers.facebook.com/docs/ios/ios9):

        const int cRecordLenght = 986;
        const int cSpoolerLenght = 1000000;
        byte[] ba = new byte[cRecordLenght];
        byte[] baSpooler = new byte[cSpoolerLenght];

        int iRecordCounter = 0;
        int iFileCounter = 0;
        int iLenght = 0;

        long lLastSeekPosition = 0;
        long lSeekPosition = 0;

        using (FileStream fileStream = new FileStream(p_sZippedFileName, FileMode.Open, FileAccess.Read))
        {
            while (true)
            {
                fileStream.Seek(lSeekPosition, SeekOrigin.Begin);
                Console.Write("Stream begins at :" + lSeekPosition.ToString());

                using (GZipStream zipStream = new GZipStream(fileStream, CompressionMode.Decompress, true))
                {
                    while (zipStream.Read(ba, 0, cRecordLenght) > 0)
                    {
                        iRecordCounter++;
                    }
                    Console.WriteLine("\nStream: " + iFileCounter.ToString() + " Records: " + iRecordCounter.ToString() + " Pos: " + lSeekPosition.ToString() + " Pos2: " + lLastSeekPosition.ToString() +  " Len: " + ( lLastSeekPosition - lSeekPosition ).ToString() + " Len2: " + iLenght.ToString() );
                    iFileCounter++;
                }

                // where is the filepointer? Suche zwischen letzer Position und neuer Position nach 1f b8 08 08 
                // go back and look for "1f b8"
                lLastSeekPosition = fileStream.Position;
                fileStream.Seek(lSeekPosition + 4, SeekOrigin.Begin); // + 4 skip last 1F b8 08 08 pattern
                iLenght = fileStream.Read(baSpooler, 0, (int)(lLastSeekPosition - lSeekPosition));

                for (int i = 0; i < iLenght; i++)
                {
                    if ((baSpooler[i] == 0x1f) && (baSpooler[i + 1] == 0x8b) && (baSpooler[i + 2] == 0x08) && (baSpooler[i + 3] == 0x08))// Stream ends here (31 / 139)
                    {
                        lSeekPosition = lSeekPosition + i + 4;
                        break;
                    }
                }
            }
        }

以及更低版本的支持

@available(iOS 9.0, *)
func application(application: UIApplication,openURL url: NSURL, options: [String: AnyObject]) -> Bool {
return FBSDKApplicationDelegate.sharedInstance().application(application, 
     openURL: url, 
     sourceApplication: options[UIApplicationOpenURLOptionsSourceApplicationKey] as! String,
     annotation: options [UIApplicationOpenURLOptionsAnnotationKey])
}