Changing a UILable in a UITextView without removing or adding objects from the library

Is it possible in Xcode to change a UILabel to a UITextView without removing the label, and then add a text view. I thought you could change the class, but it can only find UILabel .

Suppose I added 10 tags, added all the restrictions, and then realized that I needed text elements. instead of deleting them all, can I somehow change the class of objects, which then updates IB?

+7
ios uilabel xcode interface-builder uitextview
source share
3 answers

This is a significant annoyance with IB. If you modify the view object in the identity inspector, this seems to work. The problem is that the properties of the object in IB are configured the first time they are added. IB will continue to show settings for the old type.

If you change the view to a different type, the properties specified in the attribute inspector and other tabs in IB do not change as they should.

If, on the other hand, you delete the previous object and add an instance of a new type of object, your restrictions, exits and actions are lost.

The other day, I found that if I select a group of objects in IB and select "embed in view", then it removes all the restrictions from the newly implemented objects. ARGGGH! I had a rather complicated set of views and controls, and I had all the settings and restrictions that were set so that they looked right and resized, and then I realized that I needed them to be enclosed in a view. Choosing "embed in view", I returned again at the beginning and probably spent 15 or 20 minutes to get the restrictions again.

+4
source share

Editing a storyboard since plain xml is a very bad idea. If you want the text view instead of UILabel to be related to the fact that you expect different behavior for each of them, so I think the best solution is to delete and run with text views.

+1
source share

While I agree with other answers regarding caution when modifying XML directly, I found the need to make similar changes and did this while keeping my limitations intact and successful.

Make sure you use the control source so that you can discard the changes if necessary.

I suggest changing the properties of your modified work item control of a new type created in the interface builder.

Example

To move from a label to a text field, you change the "label" tag in XML to "textField".

 <label opaque="NO" ... </label> 

becomes

 <textField opaque:NO ... </textField> 

where "..." are the other attributes and controls of the control.

After changing the element tag, change the attributes of the element in accordance with the text field (in this case) to another text field created in the interface builder. Be careful that the id attribute is not changed; the id attribute is how your constraints are mapped to the control.

Save the file, and then run the file again in the interface builder. If the interface designer can parse the file, you can resume it as usual.

Again, be careful, but it can be a big time saver.

0
source share

All Articles