为什么我的工具栏被缩小尺寸? [英] Why is my Toolbar getting chopped off in compact size?

查看:528
本文介绍了为什么我的工具栏被缩小尺寸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从下面可以看出,我的工具栏在紧凑的大小上被切断:





我的UI包含一个ToolBar和一个WebView。我尝试的约束不工作,虽然我没有让他们变蓝。如你所见,我的工具栏固定在顶部,左侧和右侧(我也设置了一个恒定的高度)。



如何获得我的





>



Edit2:



这里是我做的事情来正确显示:


  1. 我不得不将WebView的边缘一直拖到(通用)故事板的边缘,以便网页不显示砍断。


  2. 我固定(编辑>固定)ToolBar的前缘,后缘和顶部边缘到Superview。我也按Ctrl +在工具栏的灰色部分垂直拖动以设置一个常量高度。


  3. 我固定(Editor> Pin)WebView的前缘,


  4. I Ctrl +从WebView垂直拖动到工具栏并选择垂直间距以使它们之间的间距是非常不变的。


  5. 我在链接添加了另一个答案的代码,使UITextField扩展或缩小以适应可用空间。请注意,Preview无法查看代码,因此您必须实际运行应用程序,以确保UITextField实际上收缩并扩展到设备的大小。


这是屏幕截图:



解决方案

好的,我做了几个测试,我注意到你的工具栏实际上正确调整大小(实际上你可以看到下面的灰色背景)。



我认为问题是工具栏 TextField和BarButtons:它们有固定的大小,所以当你改变你的视图,它看起来像工具栏 chopped (但实际上,其中的项目 clipped )。



所以,如果我没有错,你的约束是现货,但你想看看这个 question\answers这里SO SO



让我知道! :)


As can be seen below, my toolbar gets chopped off in the compact size:

My UI consists of a ToolBar and a WebView. The constraints I tried don't work, although I did get them to turn blue. As you can see, my toolbar is pinned to the top, the left side, and the right side (I also set a constant height).

How can I get my toolbar to display correctly in the compact size.

Thanks.

Edit1:

Edit2:

Here is what I did to get things to display correctly:

  1. I had to drag the edges of the WebView all the way to the edge of the (universal) storyboard in order for web pages to display without getting chopped off.

  2. I pinned (Editor>Pin) the ToolBar's leading edge, trailing edge, and top edge to the Superview. I also Ctrl+dragged vertically on a gray part of the ToolBar to set a constant Height.

  3. I pinned (Editor>Pin) the WebView's leading edge, trailing edge, and bottom edge to the Superview.

  4. I Ctrl+dragged vertically from the WebView to the ToolBar and selected Vertical Spacing to make the spacing between them(which is none) constant.

  5. I added the code at the link to the other answer to make the UITextField stretch or shrink to fit the available space. Note that Preview cannot see the code, so you have to actually Run your app to see that the UITextField does in fact shrink and expand to the size of the device.

Here's a screen shot:

解决方案

Ok, I did a few tests and I noticed that your Toolbar is actually resizing properly (in fact you can see the grey background underneath).

I think the problem are the items inside of the Toolbar, the TextField and the BarButtons: they have fixed sizes, so when you change your view, it looks like the Toolbar is chopped (but, in fact, the items inside it are clipped).

So, if I'm not wrong, your constraints are spot on, but you want to take a look at this question\answers here on SO

Let me know! :)

这篇关于为什么我的工具栏被缩小尺寸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆