0

是否可以使用 Nativescript 显示屏幕我在 Internet 上搜索的信息很少。找到了代码。

const GameViewController = (UIViewController as any).extend(
{
    get willPopCb() { return this._willPopCb; },
    set willPopCb(x) { this._willPopCb = x; },
    viewDidLoad: function(){
        UIViewController.prototype.viewDidLoad.apply(this, arguments);

        this.view = SKView.alloc().initWithFrame(this.view.bounds);
        if(this.view instanceof SKView){
            const scene = BattlefieldScene.alloc().initWithSize(
                this.view.bounds.size
            );
            scene.view.backgroundColor = UIColor.alloc().initWithRedGreenBlueAlpha(0,1,0,1);

            scene.scaleMode = SKSceneScaleMode.AspectFill;

            this.view.presentScene(scene);
            this.view.showsPhysics = false;
            this.view.ignoresSiblingOrder = true;
            this.view.showsFPS = true;
            this.view.showsNodeCount = true;
        }
    },
    willMoveToParentViewController: function(parent: UIViewController|null){
        if(parent === null){
            if(this.willPopCb){
                this.willPopCb();
            }
        }
    }
},
{
    name: "GameViewController",
    protocols: [],
    exposedMethods: {}
}

);

现在,我不明白如何显示这个控制器

先感谢您

4

1 回答 1

1

尝试,

import * as utils from "tns-core-modules/utils/utils";

const gameViewController = GameViewController.alloc().init();
const app = utils.ios.getter(UIApplication, UIApplication.sharedApplication);
app.keyWindow.rootViewController.presentViewControllerAnimatedCompletion(gameViewController, true, null);
于 2019-05-03T19:22:46.573 回答