javascript 在 iOS 模拟器上测试 Web 应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5535404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-25 17:32:42  来源:igfitidea点击:

Test Web application on iOS Simulator

javascripthtmliosipad

提问by testndtv

I am trying to optimize my website for iPad. Could you please guide me on the best approach:

我正在尝试针对 iPad 优化我的网站。你能指导我最好的方法吗:

  1. In terms of whether I should separate desktop/ipad just by CSS or redirect to an entirely different domain (e.g. mysite.com/ipad)

  2. How do I test on iPad simulator? Should I use XCode for development?

  1. 关于我是否应该仅通过 CSS 分离桌面/ipad 或重定向到完全不同的域(例如 mysite.com/ipad)

  2. 如何在 iPad 模拟器上测试?我应该使用 XCode 进行开发吗?

Please help me with some good online tutorials. Thank you.

请帮我提供一些好的在线教程。谢谢你。

采纳答案by Xand94

best to either use separate css files or just make a complete liquid layout,

最好要么使用单独的 css 文件,要么只做一个完整的液体布局,

as far as testing goes, you can download the ipad dev kit with xcode for the emulator

就测试而言,您可以为模拟器下载带有 xcode 的 ipad 开发套件

回答by Jason

Once you are in iOS simulator, go to "Hardware > Device > iPad"

进入 iOS 模拟器后,转到“硬件 > 设备 > iPad”

回答by iOSDevSF

This online iPad Simulator http://alexw.me/ipad2/will allow you to test your page along with CSS3 and javascript.

这个在线 iPad 模拟器http://alexw.me/ipad2/将允许您与 CSS3 和 javascript 一起测试您的页面。

回答by Julien

Have you tried Browshot.com? You can get free credits and try a few screenshots on the iPad browser. It uses an actual mobile browser.

你试过Browshot.com吗?您可以获得免费积分并在 iPad 浏览器上尝试一些屏幕截图。它使用实际的移动浏览器。

回答by TitanFighter

For Windowsand Linuxusers who want to run iOSsimulator inside macOSusing VirtualBox.

对于想要在内部运行模拟器的WindowsLinux用户,使用.iOSmacOSVirtualBox

CURRENT SOFTWARE VERSIONS:

当前软件版本:

  1. MacOS 10.14 Mojave;
  2. VirtualBox 5.2.22;
  3. Xcode 10.
  1. MacOS 10.14 莫哈韦沙漠;
  2. VirtualBox 5.2.22;
  3. Xcode 10.

REFERENCE:

参考:

  1. Guide: How to Install macOS 10.14 Mojave on VirtualBox on Windows?.
  1. 指南:如何在 Windows 上的 VirtualBox 上安装 macOS 10.14 Mojave?.

Prepare VirtualBox:

准备 VirtualBox:

  1. Download VirtualBox for your OS;
  2. Download VirtualBox x.x.xx Oracle VM VirtualBox Extension Pack (one for all OSs);
  3. Install VirtualBox+ Extension Pack(usually by double-clicking -> OS should recognize that Extension Packmust be opened by VirtualBox);
  4. Download VirtualBox's Virtual Disk with preinstalled MacOS 10.14 Mojave
  5. Open VirtualBox;
  6. Create a new Virtual Machine using an existing virtual hard disk file;
  7. [TIP] Follow instructions in Step 5. Customizing Virtual Machine's Preferencesof the referenced guide, if you do not know how to configure Virtual Machine. The most important thing is to give MacOS at least 2 CPU cores;
  8. We need to set some configurations. Replace "Virtual Machine Name"below by the name which you used in step 6 when you were creating Virtual Machine:
  1. 为您的操作系统下载 VirtualBox
  2. 下载 VirtualBox xxxx Oracle VM VirtualBox 扩展包(适用于所有操作系统)
  3. 安装VirtualBox+ Extension Pack(通常通过双击-> OS 应该识别出Extension Pack必须由 来打开VirtualBox);
  4. 下载预装 MacOS 10.14 Mojave 的 VirtualBox 虚拟磁盘
  5. 打开VirtualBox;
  6. 使用创建一个新的虚拟机an existing virtual hard disk file
  7. [提示]如果您不知道如何配置虚拟机,请按照参考指南的步骤 5. 自定义虚拟机首选项中的说明进行操作。最重要的是给MacOS至少2个CPU内核;
  8. 我们需要设置一些配置。将"Virtual Machine Name"下面替换为您在第 6 步中创建虚拟机时使用的名称:

For Windowsusers we need to enter the next lines (line by line) in a command line:

对于Windows用户,我们需要在命令行中输入下一行(逐行):

cd "C:\Program Files\Oracle\VirtualBox\"
VBoxManage.exe modifyvm "Virtual Machine Name" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

For Linuxusers just create a file, for example myscript, with a content:

对于Linux用户,只需创建一个文件,例如myscript,包含内容:

#!/bin/bash
VBoxManage modifyvm "Virtual Machine Name" --cpuidset 00000001 000106e5 00100800 0098e3fd bfebfbff
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "iMac11,3"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiSystemVersion" "1.0"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "Iloveapple"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/smc/0/Config/DeviceKey" "ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
VBoxManage setextradata "Virtual Machine Name" "VBoxInternal/Devices/smc/0/Config/GetKeyFromRealSMC" 1

and run it in a terminal as source ./myscript.

并在终端中以source ./myscript.

Install macOS 10.14 Mojave on VirtualBox(Step 7. Install macOS 10.14 Mojave on VirtualBoxfrom the guide):

在 VirtualBox 上安装 macOS 10.14 Mojave第 7 步。从指南中的VirtualBox 上安装 macOS 10.14 Mojave):

  1. Open VirtualBox and start the created Virtual Machine;
  2. Wait for some seconds until the codes panel and apple logo go away;
  3. On the Welcome screen, select your country and select continue;
  4. Select your Keyboard layout;
  5. Select, don't transfer any information type and click continue;
  6. Decide to sign in with Apple ID or Not;
  7. Agree to the terms and conditions;
  8. Create an Account for the macOS Mojave 10.14;
  9. Choose a look for your Mac Device, whether it is the light mode or Dark Mode;
  10. Select Continue on the Express Set up window;
  11. Wait for Some seconds until your Mac is set up for use.
  1. 打开VirtualBox,启动创建好的虚拟机;
  2. 等待几秒钟,直到代码面板和苹果标志消失;
  3. 在欢迎屏幕上,选择您的国家并选择继续;
  4. 选择您的键盘布局;
  5. 选择,不传输任何信息类型,点击继续;
  6. 决定是否使用 Apple ID 登录;
  7. 同意条款与条件;
  8. 为 macOS Mojave 10.14 创建一个帐户;
  9. 为您的 Mac 设备选择外观,无论是浅色模式还是深色模式;
  10. 在快速设置窗口中选择继续;
  11. 等待几秒钟,直到您的 Mac 设置好可以使用。

Install iOS simulator:

安装iOS模拟器:

  1. Install Xcode(Click blue Download in the Top Right corner, provide your Apple ID and you will be redirected to App Store);
  2. Open Xcode(from App Storeor from Finder -> Applications -> Xcode);
  3. Select Get started with a playground+ Blankin order to skip all annoying steps.
  1. 安装Xcode(点击右上角的蓝色下载,提供您的Apple ID,您将被重定向到App Store);
  2. 打开Xcode(来自App Store或来自Finder -> Applications -> Xcode);
  3. 选择Get started with a playground+Blank以跳过所有烦人的步骤。

Test Site + Use Simulator:

测试场地+使用模拟器:

  1. ==============

    1.1. Open Xcode;

    1.2. In the top menu select Xcode -> Open Developer Tool -> Simulator;

    1.3. [TIP] You can Keep in DockSimulator, so you do not need to run Xcodeevery time;

    1.4. In the top menu select Hardware -> Deviceto select device/iOS for simulation;

    1.5. [TIP] In the top menu select Hardware -> Manage Devices...+ Simulatorstab to install a packages with other versions of iOS;

    1.6. Open your site in Simulator's iOS Safari;

  2. ==============

    2.1. Open Desktop Safari;

    2.2. In the top menu select Safari -> Preferences...+ Advancedtab -> Tick Show Develop menu in menu bar;

    2.3. In the top menu select Develop -> SIMULATED DEVICE -> YOUR SITE.

  1. ==============

    1.1. 打开Xcode;

    1.2. 在顶部菜单中选择Xcode -> Open Developer Tool -> Simulator;

    1.3. 【TIP】可以Keep in Dock模拟器,不用Xcode每次都跑;

    1.4. 在顶部菜单中选择Hardware -> Device选择用于模拟的设备/iOS;

    1.5. [提示] 在顶部菜单中选择Hardware -> Manage Devices...+ Simulatorstab 安装其他版本的 iOS 的包;

    1.6. 打开您的网站Simulator's iOS Safari

  2. ==============

    2.1. 打开桌面Safari;

    2.2. 在顶部菜单中选择Safari -> Preferences...+ Advancedtab -> Tick Show Develop menu in menu bar;

    2.3. 在顶部菜单中选择Develop -> SIMULATED DEVICE -> YOUR SITE