简体   繁体   English

创建视图-iPhone

[英]Creating Views - iPhone

Im making a simple application to learn getsure recognizers.. I have created four views in my window but when i load the application, the size is completely different to how i had arranged them before.. any ideas why or how i can fix this? 我正在制作一个简单的应用程序来学习获取识别器。.我已经在窗口中创建了四个视图,但是当我加载该应用程序时,其大小与之前的排列方式完全不同。.为什么或如何解决此问题的任何想法?

i am importing some co-ordinates in my .h file for pinching.. could this be why? 我正在.h文件中导入一些坐标以进行捏..这可能是为什么吗?

thanks 谢谢

Make sure you are setting the views' frames correctly. 确保正确设置视图的框架。 For example, if you want your view to be 100 pixels wide, 50 pixels tall, and be in the top-left corner of the window, you'd write the following: 例如,如果您希望视图的宽度为100像素,高度为50像素,并且位于窗口的左上角,则可以编写以下代码:

myView.frame = CGRectMake(0, 0, 100, 50);

If you wanted to push that view over 10 pixels to the right and 15 pixels down (but with the same dimensions), you'd write the following instead: 如果您想将该视图向右推10个像素,向下推15个像素(但尺寸相同),则可以编写以下代码:

myView.frame = CGRectMake(10, 15, 100, 50);

For more information on view frames, read through all the attributes in the "Configuring the Bounds and Frame Rectangles" section on Apple's UIView Class Reference . 有关视框的更多信息,请通读Apple的《 UIView类参考 》的“配置边界和框矩形”部分中的所有属性。

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

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