首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在SceneDelegate中使用flutter方法处理程序?

如何在SceneDelegate中使用flutter方法处理程序?
EN

Stack Overflow用户
提问于 2020-08-28 17:45:30
回答 1查看 405关注 0票数 2

我有一个音乐扑动应用程序,现在我正在实现在spotify ios sdk与spotify ios sdk集成的本地播放器代码。

我正在尝试运行,但iOS13.6手机上的spotify连接功能不起作用,我看到IOS 13+以后的版本需要SceneDelegate。

现在我纠结于如何在SceneDelegate中添加Flutter方法处理程序。

当我在SceneDelegate上添加Flutter方法处理程序时,我得到了下面的错误,它将被卡住在断点处,下一步不会执行。

我正在尝试通过遵循AVFoundation文档来制作一个简单的视频取景器。应用程序每次启动时都会终止。我如何解决这个特定的错误?

代码语言:javascript
复制
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x102d3c320)
EN

回答 1

Stack Overflow用户

发布于 2021-03-12 22:43:35

以下步骤帮助我在SceneDelegate中使用Flutter应用程序

符合UIWindowSceneDelegate

  1. 创建包含子类SceneDelegate.swiftUIResponder

代码语言:javascript
复制
@available(iOS 13.0, *)
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
    
    var window: UIWindow?
    //....

}

  1. SceneManifest添加到Info.plist,其中我们将SceneDelegate声明为scene

的默认配置

代码语言:javascript
复制
<key>UIApplicationSceneManifest</key>
    <dict>
        <key>UIApplicationSupportsMultipleScenes</key>
        <true/>
        <key>UISceneConfigurations</key>
        <dict>
            <key>UIWindowSceneSessionRoleApplication</key>
            <array>
                <dict>
                    <key>UISceneConfigurationName</key>
                    <string>Default Configuration</string>
                    <key>UISceneDelegateClassName</key>
                    <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string>
                    <key>Storyboard Name</key>
                    <string>Main</string>
                </dict>
            </array>
        </dict>
    </dict>

  1. 更新AppDelegate.swift支持iOS 13

以外的其他版本

代码语言:javascript
复制
    override func application( _ application: UIApplication,
                               didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        guard #available(iOS 13.0, *) else {
            GeneratedPluginRegistrant.register(with: self)
            guard let controller = window?.rootViewController as? FlutterViewController else { return true }
            //Confugure 'controller' as needed
            return super.application(application, didFinishLaunchingWithOptions: launchOptions)
        }
        return true
    }

支持iOS 13+的

  1. 更新SceneDelegate.swift

代码语言:javascript
复制
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

        guard let windowScene = scene as? UIWindowScene else { return }
        
        window = UIWindow(windowScene: windowScene)
        let flutterEngine = FlutterEngine(name: "SceneDelegateEngine")
        flutterEngine.run()
        GeneratedPluginRegistrant.register(with: flutterEngine)
        let controller = FlutterViewController.init(engine: flutterEngine, nibName: nil, bundle: nil)
        window?.rootViewController = controller
        window?.makeKeyAndVisible()
    }
票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63631338

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档