【问题标题】:Black Screen after displaying root view controller, ONLY when inheriting PayPalPaymentDelegate显示根视图控制器后黑屏,仅在继承 PayPalPaymentDelegate 时
【发布时间】:2016-08-01 01:53:44
【问题描述】:

问题是,当一个类继承了 PayPalPaymentDelegate 时,我在启动屏幕之后会出现黑屏

起初我以为是我的 PayPalMobile 绑定,所以我使用了 Alejandro 的 PayPalMobile binding。我使用他的绑定和我的绑定得到了相同的结果。

我运行了Alejandro sample app,它运行良好。我不知道为什么我的黑屏。

什么可能导致我的项目出现此问题?

到目前为止我做了什么:

我将部署目标从 8.4 更改为 9.2,并将主界面从 none 更改为 LoginViewController 并收到相同的问题。

制作了一个新的解决方案,添加了我的 PayPalMobile 绑定,并且成功了。

根视图控制器在进入黑屏之前会显示。

所以,解决方案中出现了问题,我不知道是什么原因。

环境:

我使用的是最新的 PayPal 手机

使用 Xamarin Studio 5.10.2

使用 iPhone 6s 9.2 模拟器

Info.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>CFBundleDisplayName</key>
    <string>Test</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0</string>
    <key>CFBundleVersion</key>
    <string>1.0</string>
    <key>LSRequiresIPhoneOS</key>
    <true/>
    <key>MinimumOSVersion</key>
    <string>9.2</string>
    <key>UIDeviceFamily</key>
    <array>
        <integer>1</integer>
    </array>
    <key>UILaunchStoryboardName</key>
    <string>LaunchScreen</string>
    <key>UIRequiredDeviceCapabilities</key>
    <array>
        <string>armv7</string>
    </array>
    <key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleLightContent</string>
    <key>CFBundleIconFiles</key>
    <array>
        <string>Icon</string>
    </array>
    <key>UIBackgroundModes</key>
    <array>
        <string>location</string>
    </array>
    <key>CFBundleDocumentTypes</key>
    <array>
        <dict>
            <key>CFBundleTypeName</key>
            <string>MKDirectionsRequest</string>
            <key>LSItemContentTypes</key>
            <array>
                <string>com.apple.maps.directionsrequest</string>
            </array>
        </dict>
    </array>
    <key>MKDirectionsApplicationSupportedModes</key>
    <array>
        <string>MKDirectionsModeCar</string>
    </array>
    <key>XSLaunchImageAssets</key>
    <string>Resources/Images.xcassets/LaunchImage.launchimage</string>
    <key>CFBundleIdentifier</key>
    <string>email@yahoo.com</string>
    <key>UIMainNibFile</key>
    <string>LoginViewController</string>
</dict>
</plist>

【问题讨论】:

  • UIApplication.SharedApplication.KeyWindow.RootViewController 的值是多少?它应该是您的自定义UIViewController。该对象的View 属性的值是多少?那应该是您的根UIView(全黑)。 Views Frame 属性的价值是多少?尝试将其设置为UIScreen.MainScreen.Bounds
  • 谢谢,但我发现了问题。在 AppDelegate 中,我将 UIWindow 类作为替代,并且它起作用了

标签: ios paypal xamarin xamarin.ios


【解决方案1】:

好的,我找到了问题。

在 AppDelegate 中,我在 FinishedLaunching() 方法中定义了 UIWindow。

将 UIWindow 类设置为覆盖,修复了问题。

在 AppDelegate 中:

public partial class AppDelegate : UIApplicationDelegate 
{
    // This fixed the problem    
    public override UIWindow Window {
        get;
        set;
    }

    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {    
        //This cause the black screen
        //UIWindow Window = new UIWindow (UIScreen.MainScreen.Bounds);
        Window = new UIWindow (UIScreen.MainScreen.Bounds);

        UINavigationController navController = 
                new UINavigationController (new ViewController ());
        Window.RootViewController = navController;
        Window.MakeKeyAndVisible();

        return true;
    }
}

【讨论】:

    【解决方案2】:

    检查 info.plist 文件,看看您的项目是否缺少某些东西

    【讨论】:

    • 谢谢。我到底在寻找什么?
    • 您错过了 LSApplicationQueriesSchemes 和 CFBundleURLTypes 使用此作为参考 github.com/AlejandroRuiz/PayPal.Forms/blob/master/MobileApps/…,也请阅读 github.com/paypal/PayPal-iOS-SDK 配置指南
    • 谢谢。但是,当我创建一个新项目并添加它工作的 PayPal 库并查看它的 Info.plist 时,它没有这两个名称。如何添加这两个缺失的键?
    • 添加到您的 info.plist 文件中
    • 我添加了这两个键并没有解决问题。加载根视图控制器后屏幕立即变黑。
    猜你喜欢
    • 2012-08-13
    • 2019-12-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多