首页 > 解决方案 > iPad 上的 Codenameone 应用程序在每隔一段时间从睡眠状态开始时使用错误的纵横比

问题描述

首先,我是代号的新手,所以如果解决方案很明显,我很抱歉。我有一个问题,我的代号应用程序在从后台启动后确实调整了当前表单的大小,但只是在 iPad 上。它只会每隔一个恢复一次,所以一次正常,背景,调整大小的格式,背景,正常。

在模拟器和 iPhone 上的行为是正常的,只是 iPad 搞砸了。

有人可以指点我一个方向吗?我认为某些东西可能会被调用两次,但我不知道是什么...... onstart() 和 onStop() 的代码示例和照片已附上..

谢谢!

rgds Vinc

public void start() {
    if (current != null) {
        current.show();
        return;
    }
    Controller.showSplash(); // go to splash screen. Splash screen forwards to mainMenu();
}

public void stop() {
    current = getCurrentForm();
    if (current instanceof Dialog) {
        ((Dialog) current).dispose();
        current = getCurrentForm();
    }
}

//GUI生成器代码

public MainMenu(com.codename1.ui.util.Resources resourceObjectInstance) {
    initGuiBuilderComponents(resourceObjectInstance);
}

protected com.codename1.ui.Label gui_Label = new com.codename1.ui.Label();
protected com.codename1.ui.Container gui_Box_Layout_Y = new com.codename1.ui.Container(new com.codename1.ui.layouts.GridLayout(1, 1));
protected com.codename1.components.ScaleImageButton gui_Scaled_Button = new com.codename1.components.ScaleImageButton();
protected com.codename1.components.ScaleImageButton gui_Scaled_Button_1 = new com.codename1.components.ScaleImageButton();
protected com.codename1.components.ScaleImageButton gui_Scaled_Button_2 = new com.codename1.components.ScaleImageButton();
protected com.codename1.ui.Label gui_Label_1 = new com.codename1.ui.Label();
protected com.codename1.ui.Button gui_Button = new com.codename1.ui.Button();

private void guiBuilderBindComponentListeners() {
    EventCallbackClass callback = new EventCallbackClass();
    gui_Scaled_Button.addActionListener(callback);
    gui_Scaled_Button_1.addActionListener(callback);
    gui_Scaled_Button_2.addActionListener(callback);
    gui_Button.addActionListener(callback);
}

class EventCallbackClass implements com.codename1.ui.events.ActionListener, com.codename1.ui.events.DataChangedListener {
    private com.codename1.ui.Component cmp;
    public EventCallbackClass(com.codename1.ui.Component cmp) {
        this.cmp = cmp;
    }

    public EventCallbackClass() {
    }

    public void actionPerformed(com.codename1.ui.events.ActionEvent ev) {
        com.codename1.ui.Component sourceComponent = ev.getComponent();

        if(sourceComponent.getParent().getLeadParent() != null && (sourceComponent.getParent().getLeadParent() instanceof com.codename1.components.MultiButton || sourceComponent.getParent().getLeadParent() instanceof com.codename1.components.SpanButton)) {
            sourceComponent = sourceComponent.getParent().getLeadParent();
        }

        if(sourceComponent == gui_Scaled_Button) {
            onScaled_ButtonActionEvent(ev);
        }
        if(sourceComponent == gui_Scaled_Button_1) {
            onScaled_Button_1ActionEvent(ev);
        }
        if(sourceComponent == gui_Scaled_Button_2) {
            onScaled_Button_2ActionEvent(ev);
        }
        if(sourceComponent == gui_Button) {
            onButtonActionEvent(ev);
        }
    }

    public void dataChanged(int type, int index) {
    }
}
private void initGuiBuilderComponents(com.codename1.ui.util.Resources resourceObjectInstance) {
    guiBuilderBindComponentListeners();
    setLayout(new com.codename1.ui.layouts.LayeredLayout());
    setInlineStylesTheme(resourceObjectInstance);
    setScrollableX(false);
    setScrollableY(false);
            setInlineStylesTheme(resourceObjectInstance);
    setInlineAllStyles("fgColor:ffffff; opacity:220;");
    setTitle("");
    setName("ToolBox");
    ((com.codename1.ui.layouts.LayeredLayout)getLayout()).setPreferredWidthMM((float)156.8586);
    ((com.codename1.ui.layouts.LayeredLayout)getLayout()).setPreferredHeightMM((float)171.04149);
    addComponent(gui_Label);
    addComponent(gui_Box_Layout_Y);
    gui_Box_Layout_Y.setPreferredSizeStr("64.9873mm 52.921253mm");
            gui_Box_Layout_Y.setInlineStylesTheme(resourceObjectInstance);
    gui_Box_Layout_Y.setName("Box_Layout_Y");
    ((com.codename1.ui.layouts.LayeredLayout)gui_Box_Layout_Y.getParent().getLayout()).setInsets(gui_Box_Layout_Y, "24.82299% auto 28.533901% auto").setReferenceComponents(gui_Box_Layout_Y, "-1 -1 0 -1").setReferencePositions(gui_Box_Layout_Y, "0.0 0.0 1.0 0.0");
    gui_Box_Layout_Y.addComponent(gui_Scaled_Button);
    gui_Box_Layout_Y.addComponent(gui_Scaled_Button_1);
    gui_Box_Layout_Y.addComponent(gui_Scaled_Button_2);
            gui_Scaled_Button.setInlineStylesTheme(resourceObjectInstance);
    gui_Scaled_Button.setName("Scaled_Button");
    gui_Scaled_Button.setIcon(resourceObjectInstance.getImage("CrewRest_V02.jpg"));
            gui_Scaled_Button_1.setInlineStylesTheme(resourceObjectInstance);
    gui_Scaled_Button_1.setName("Scaled_Button_1");
    gui_Scaled_Button_1.setIcon(resourceObjectInstance.getImage("Fuel_V02.jpg"));
            gui_Scaled_Button_2.setInlineStylesTheme(resourceObjectInstance);
    gui_Scaled_Button_2.setName("Scaled_Button_2");
    gui_Scaled_Button_2.setIcon(resourceObjectInstance.getImage("Snowtam_V02.jpg"));
    addComponent(gui_Label_1);
    addComponent(gui_Button);
    gui_Label.setPreferredSizeStr("182.2608mm 10.0mm");
    gui_Label.setUIID("LabelGrey");
            gui_Label.setInlineStylesTheme(resourceObjectInstance);
    gui_Label.setInlineAllStyles("bgColor:5f6a6d; transparency:255; opacity:255; margin:0.0mm 0.0mm 0.0mm 0.0mm;");
    gui_Label.setName("Label");
    ((com.codename1.ui.layouts.LayeredLayout)gui_Label.getParent().getLayout()).setInsets(gui_Label, "92.31431% 0.0mm 0.0mm 0.0mm").setReferenceComponents(gui_Label, "-1 -1 -1 -1").setReferencePositions(gui_Label, "0.0 0.0 0.0 0.0");
    gui_Box_Layout_Y.setPreferredSizeStr("64.9873mm 52.921253mm");
            gui_Box_Layout_Y.setInlineStylesTheme(resourceObjectInstance);
    gui_Box_Layout_Y.setName("Box_Layout_Y");
    ((com.codename1.ui.layouts.LayeredLayout)gui_Box_Layout_Y.getParent().getLayout()).setInsets(gui_Box_Layout_Y, "24.82299% auto 28.533901% auto").setReferenceComponents(gui_Box_Layout_Y, "-1 -1 0 -1").setReferencePositions(gui_Box_Layout_Y, "0.0 0.0 1.0 0.0");
            gui_Label_1.setInlineStylesTheme(resourceObjectInstance);
    gui_Label_1.setInlineAllStyles("bgColor:ffffff; transparency:255;");
    gui_Label_1.setName("Label_1");
    gui_Label_1.setIcon(resourceObjectInstance.getImage("AeroLogic_Logo.jpg"));
    ((com.codename1.ui.layouts.LayeredLayout)gui_Label_1.getParent().getLayout()).setInsets(gui_Label_1, "0.0mm auto auto auto").setReferenceComponents(gui_Label_1, "-1 -1 -1 -1").setReferencePositions(gui_Label_1, "0.0 0.0 0.0 0.0");
    gui_Button.setPreferredSizeStr("7.1972904mm 4.022015mm");
    gui_Button.setUIID("ButtonInfo");
            gui_Button.setInlineStylesTheme(resourceObjectInstance);
    gui_Button.setInlineAllStyles("fgColor:ffffff;");
    gui_Button.setName("Button");
    com.codename1.ui.FontImage.setMaterialIcon(gui_Button,"\ue88e".charAt(0));
    ((com.codename1.ui.layouts.LayeredLayout)gui_Button.getParent().getLayout()).setInsets(gui_Button, "auto 2.3285353mm auto auto").setReferenceComponents(gui_Button, "0 0 0 -1").setReferencePositions(gui_Button, "0.0 0.0 0.0 0.0");
}// </editor-fold>

简历后

每隔一秒恢复正常

标签: javaioscodenameone

解决方案


推荐阅读