菜鸟教程小白 发表于 2022-12-11 22:07:34

objective-c - iOS第二屏


                                            <p><p>我正在使用 PhoneGap ExternalScreen 插件,但我对其进行了一些修改,以便能够支持多种分辨率。我从 Matt Gemmel 在 iPadVGAOutput (http://mattgemmell.com/2010/06/01/ipad-vga-output/) 上的帖子中得到了一些提示,我的代码如下所示:</p>

<pre><code>- (void) toggleResolution:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options
{
    self.callbackID = ;
    if ([ count] &gt; 1){
      externalScreen = [[ objectAtIndex:1] retain];
      screenModes = ;
      UIAlertView *alert = [[ initWithTitle:@&#34;External Display Size&#34;
                                                    message:@&#34;Choose a size for the external display.&#34;
                                                    delegate:self
                                                    cancelButtonTitle:nil
                                                    otherButtonTitles:nil] autorelease];

      for (UIScreenMode *mode in screenModes){
            CGSize modeScreenSize = mode.size;
            ];
      }
      ;
    } else {
      PluginResult* pluginResult = ;
      ];
    }   
}



- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    UIScreenMode *desiredMode = ;
    externalScreen.currentMode = desiredMode;
    externalWindow.screen = externalScreen;   
    ;

    CGRect rect = CGRectZero;
    rect.size = desiredMode.size;
    externalWindow.frame = rect;
    externalWindow.clipsToBounds = YES;

    externalWindow.hidden = NO;
    ;

    PluginResult* pluginResult = ;
    ];
}
</code></pre>

<p>分辨率变化得很好,但内容并没有被限制在正确的尺寸内。一个例子如下:</p>

<p>最初加载第二个屏幕时(1920x1080),它看起来像这样:<a href="http://cl.ly/F5IV" rel="noreferrer noopener nofollow">http://cl.ly/F5IV</a> </p>

<p>将分辨率更改为 1280x720 后,如下所示:<a href="http://cl.ly/F41K" rel="noreferrer noopener nofollow">http://cl.ly/F41K</a> </p>

<p>我对 Objective-C 比较陌生,但很快就学会了。任何有关解决我的问题和/或完全改进代码的指示都会很棒。谢谢!</p>

<p>安德鲁</p>

<p><em><strong>编辑</strong>:我还想澄清一下,我没有手动设置任何正在显示的 View 和/或 CSS 的宽度/高度。</em></em> p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>由于没有人发现它,我开始深入研究Objective-C并解决了它。我必须在 <code>alertView</code> 方法中添加以下内容:</p>

<pre><code>webView.frame = rect;
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - iOS第二屏,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/9727449/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/9727449/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - iOS第二屏