How to change textfield height for an ipad using interface builder?

不羁岁月 提交于 2019-12-07 12:46:16

问题


We're using Interface Builder for developing an app for the iPad and we can't figure out how to increase the height of the textfields.

When we were using IB to develop an application for osx, you could go to the textfields attributes and under the control section you could set line break to word wrap instead of clip.

When we try to use Interface Builder for iPad applications though, it doesn't have the option of changing linebreak style under attributes-->control.

Is there any way to set the height using Interface Builder or do you have to set that in the code?


回答1:


It looks like the height of the rounded-style text field is locked in Interface Builder. My solution was to use another of the UITextField styles in my XIB and then call textField.borderStyle = UITextBorderStyleRoundedRect in my viewDidLoad method.

Of course, textField should be the name of the UITextField IBOutlet.




回答2:


iOS UITextFields are single line only and have a fixed height.

If you want a multi-line, variable-height text entry field then use UITextView.




回答3:


1 - Right click on your storyboard/xib file and select "Open as" -> "Source code".

2 - Find the xml tag relative to your TextField, e.g.

<textField opaque="NO" clipsSubviews="YES" tag="102" contentMode="scaleToFill" misplaced="YES" contentHorizontalAlignment="left" contentVerticalAlignment="center" text="6872" borderStyle="roundedRect" placeholder="Password" textAlignment="natural" minimumFontSize="17" translatesAutoresizingMaskIntoConstraints="NO" id="Dxw-lR-kq5">
<rect key="frame" x="20" y="337" width="335" height="30"/>

3 - Change the height value to what you want (e.g. 50)

4 - Right click again on you storyboard and select "Open as" -> "Interface builder"

5 - See the result




回答4:


there is a wrapping text field,that is what you need.




回答5:


set the frame of ui textfield object in view did load but it will involve coding

[self.searchText setFrame:CGRectMake(180, 450, 400, 250)];
//in my case the object was called search text...



回答6:


You can edit the height of any UITextfield in IB.Just set the constraint in IB.Select the constraint.In the Size Inspector-->Select and Edit just change the constant to your desired value.Press Enter ...Done!!!! (Can't get multiline though)



来源:https://stackoverflow.com/questions/3728522/how-to-change-textfield-height-for-an-ipad-using-interface-builder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!