简体   繁体   English

无法在iOS模拟器中缩放设备窗口

[英]Can't scale device window in iOS Simulator

On the 24" iMac I'm using at work I cannot scale the iOS Simulator's window. The 100% and 50% menu entries are greyed out (and the keyboard shortcuts don't work either.) 在我正在使用的24英寸iMac上,我无法缩放iOS模拟器的窗口.100%和50%的菜单条目显示为灰色(键盘快捷键也不起作用。)

On my Mac Mini at home, it's fine. 在家里的Mac Mini上,没关系。 I've searched high and low for someone with a similar problem, and can't find anything logged. 我已经搜索过具有类似问题的人的高低,并且找不到任何记录。 Any ideas? 有任何想法吗?

Now It's more flexible with Xcode 9+ Simulator. 现在使用Xcode 9+模拟器更灵活。 You can pick & drag any corner of simulator to resize it and set it according to your requirement. 您可以选择并拖动模拟器的任何角落以调整其大小并根据您的要求进行设置。

Look at this snapshot. 看看这个快照。

在此输入图像描述

Note: With Xcode 9.1+, Simulator scale options are changed. 注意:使用Xcode 9.1+,可以更改模拟器比例选项。



There are several other ways also, to scale your simulator. 还有其他几种方法可以扩展您的模拟器。

Keyboard short-keys : 键盘快捷键
According to Xcode 9.1+ 根据Xcode 9.1+

Physical Size       ⌘ 1      command + 1
Pixel Accurate      ⌘ 2      command + 2


According to Xcode 9 根据Xcode 9

50% Scale           ⌘ 1      command + 1
100% Scale          ⌘ 2      command + 2
200% Scale          ⌘ 3      command + 3



Simulator scale options Menu : 模拟器比例选项菜单
Xcode 9.1+: Xcode 9.1+:

Menubar ▶ Window ▶ "Here, options available to change simulator scale" (Physical Size & Pixel Accurate) 菜单栏▶窗口▶“这里,可用于更改模拟器比例的选项” (物理尺寸和像素精度)

Pixel Accurate: Resizes your simulator to actual (Physical) device's pixels, if your mac system display screen size (pixel) supports that much high resolution, else this option will remain disabled. 像素精确:如果您的mac系统显示屏幕尺寸(像素)支持那么高的分辨率,则将模拟器的大小调整为实际(物理)设备的像素,否则此选项将保持禁用状态。

在此输入图像描述


Xcode 9.0: Xcode 9.0:

Menubar ▶ Window ▶ Scale ▶ "Here, options available to change simulator scale" 菜单栏▶窗口▶刻度▶“这里,可用于更改模拟器刻度的选项”

在此输入图像描述



Using Terminal Command 使用终端命令
Follow these steps to scale simulator using terminal commands 按照以下步骤使用终端命令缩放模拟器

  1. Close/Quit simulator. 关闭/退出模拟器。 (if open) (如果打开)
  2. Open Terminal app (using Spotlight search, Press ⌘ + SPACE to open spotlight search) 打开Terminal应用(使用Spotlight搜索,按⌘ + SPACE打开聚光灯搜索)
  3. Copy following text and paste it next to terminal cursor. 复制以下文本并将其粘贴到终端光标旁边。

defaults write ~/Library/Preferences/com.apple.iphonesimulator SimulatorWindowLastScale "0.3"

  1. Open 'Simulator' (Run your iOS project using Xcode). 打开'模拟器'(使用Xcode运行您的iOS项目)。

You will find simulator scale update. 你会发现模拟器规模更新。

如果您的屏幕不够大,无法将窗口显示为100%,则选项将仅存在。

For Xcode 9, we detect the size of your screen. 对于Xcode 9,我们检测屏幕的大小。 If it isn't large enough to display the window we disable the relevant scaling option. 如果它不足以显示窗口,我们将禁用相关的缩放选项。

As Krunal points out you can now drag to scale the window to whatever arbitrary size you want so this shouldn't be a problem. 正如Krunal指出的那样,您现在可以拖动以将窗口缩放到您想要的任意大小,因此这应该不是问题。 (In previous releases you could only pick from pre-defined sizes; the window itself was not resizable). (在以前的版本中,您只能从预定义的大小中选择;窗口本身不可调整大小)。

I solved this problem by changing the resolution of my Macbook Pro screen to biggest supported value, And increase the size of the simulator by drag and it's work! 我通过将我的Macbook Pro屏幕的分辨率更改为最大支持值来解决了这个问题,并通过拖动增加了模拟器的大小并且它的工作! I can now attach iPad screenshot. 我现在可以附上iPad截图了。 Thanks Apple it's totally easy like always!. 感谢Apple,它总是很容易!

I can confirm that @Abdulaziz Noor method of changing the resolution of your mac display works. 我可以确认@Abdulaziz Noor改变mac显示器分辨率的方法有效。

Steps I took: 我采取的步骤:

System Preferences -> Displays -> Display -> Scaled -> More Space 

如果你只想要一个100%的屏幕截图,你可以将其拖动到至少100%的任何位置,截图将与100%截图相同。

即使在xcode9中,如果您的屏幕无法容纳,也不会让缩放设置为100%,但您可以作弊.. ..只选择横向,如果设备的宽度适合屏幕的高度,您可以选择100%,然后旋转设备,即使它不适合屏幕。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM