简体   繁体   English

UITextfield自定义位置因iPhone尺寸不同而上升

[英]UITextfield Custom Position moved up because of different iPhone sizes

I have several custom UITextfields in my app. 我的应用程序中有几个自定义UITextfields。 I started this app on Xcode 5 and ran on iphone 5 simulator. 我在Xcode 5上启动了此应用,并在iPhone 5模拟器上运行。 After Xcode updated to Xcode 6, I ran the app on iPhone 6 simulator. Xcode更新到Xcode 6之后,我在iPhone 6模拟器上运行了该应用程序。 Now all the textfield positions moved up because of large screen size. 现在,由于大屏幕尺寸,所有文本字段位置都向上移动。 I just wanted to know is there anything I could do so that the positions of textfields automatically get adjusted depending upon the iPhone models. 我只是想知道我能做些什么,以便根据iPhone型号自动调整文本字段的位置。

You need to rebuild your interface to handle the different screen sizes. 您需要重建界面以处理不同的屏幕尺寸。 In particular, you need to work with the AutoLayout feature to help determine how you want everything to scale/move/position based on multiple screen sizes. 特别是,您需要使用“自动版式”功能来帮助确定如何根据多种屏幕尺寸缩放/移动/放置所有内容。 This can be done via the Storyboard (easier but sometimes frustrating) or in code (harder at first but more control later). 这可以通过情节提要(更简单,但有时令人沮丧)或代码(起初较难,但以后进行更多控制)来完成。 I usually use Storyboards and it's worked great on several projects. 我通常使用情节提要,它在多个项目中都非常有效。

Do you want it centered and respecting your original layout and margins? 您是否希望它居中并尊重您的原始布局和边距? a certain distance from the top or sides? 与顶部或侧面有一定距离? everything scaled up appropriately? 一切都适当扩大了吗? All these things can be done with AutoLayouts. 所有这些事情都可以通过AutoLayouts完成。

Check out the great tutorial here for more information: http://www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1 在此处查看出色的教程以了解更多信息: http : //www.raywenderlich.com/50317/beginning-auto-layout-tutorial-in-ios-7-part-1

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

相关问题 在相同的UITextField中居中占位符,但大小不同 - centering placeholder in the same UITextField, but of two different sizes 适用于不同iPhone尺寸的多个情节提要 - Multiple storyboards for different iPhone sizes Xcode Storyboard - 如何在不同的iPhone屏幕尺寸之间更改元素的字体大小和位置 - Xcode Storyboard - How to change font size and position of elements between different iPhone screen sizes 在cocos2d 2中,给定iPhone不同的大小,有条件地定位和显示Sprite - Conditionally position and display sprite given iphone different sizes in cocos2d 2 iPhone 检测到用户向上移动了他们的设备 - iPhone detect that user moved up their device UISearchbar上的UITextfield在模拟器和实际iPhone上看起来有所不同 - UITextfield at UISearchbar appears different at simulator and on actual iPhone UILabel处于2种不同屏幕尺寸的不同位置 - UILabel in different position for 2 different screen sizes Swift:锁定按钮位置是因为UITextview正在移动它? 约束有问题吗? - Swift: Lock button position because it is being moved by UITextview? Problems with constraints? 如何设置UITextField的自定义光标位置? - How to set custom cursor position of UITextField? 自定义UICollectionViewLayout不同的单元格大小 - Custom UICollectionViewLayout Different Cell Sizes
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM