Adjust UITextfield width - ios

I have a UITextField inside of a table cell and am trying to use interface builder to extend the width. However no matter how much I drag it, it remains at 97. Am I not allowed to extend it for some reason? Thanks
EDIT: Attempting to edit the text or increasing the font truncates the text..the UITextField will not change dimensions to accommodate it - it remains at 97 x 30.

Interface builder is tricky when it comes to some thing.
Your best bet is to modify the text field's frame in cellForRowAtIndexPath: in tableview's datasource method. That should fix this kind of problems.

Related

Constraints making UITextView smaller

I just put constraints into my ViewController, and I set the UITextView so that it keeps its height and width, yet at runtime it shrinks to only cover the text inside of it. How can I avoid this?
Thank you!
In my opinion, at the run time, the size of your TextView has changed because of the content, I mean the text set to it. To prevent this kind of issue, I would suggest some options which will be regarding your UI
At first, if you intend to fix size of the TextView, so from the constraints or Interface Builder, please create width and height constraints then fix the value. For example
If you wish your text view will be dynamically in size based on contents, you can set width and height values are greater than or equal a minimum value as it will not break your UI
I hope this would be helpful.
I assume you're using Interface Builder. Check the value for Content Hugging Priority that IB set for the text view. If it's too high, it may be overriding your constraints.

Autoshrink in UILabel only for width?

I have some ASCII syntax diagrams which must not have line breaks in the middle.
These don't have to be editable so I thought the best way is to use an UILabel with auto shrink option. But this option shrinks the text also if the content doesn't fit the height of the labels frame rectangle.
I just want to shrink only if the content doesn't fit the width. It would be absolutely fine to scroll vertically through the text.
What is the best way to do this with UILabel or any other UI element?
Use UITextView with 'editable' property set to false.
So let me rephrase your question. I guess what you want is a UILabel which can show multiple lines, but the longest line need to fit into the width of UILabel. If this is what you want, well the imagination is weird to me...
But anyway, I feel there's a conflict in your settings. First, allowing multiple lines implies you set "Lines" attribute (number of lines) as 0, which allows unlimited lines. But then Autoshrink will play no effect. I'm afraid it is not possible to be done by just setting the storyboard and instead, you need to write some code.
I guess people have raised related questions earlier, by which they want to dynamically change the font size when the text become too long. I guess you want to take a look about this:
Autoshrink on a UILabel with multiple lines
The last issue is you also want the scrolling effect (this is why I feel the outlooking will be weird.) But in short, to achieve this you need 1) dynamically change the UILabel height, most likely using the same technique as explained in the reference thread, and 2) wrap the UILabel in a scroll view. Maybe this can achieve what you want.

Multiline UILabel with auto layout does not work

I'm trying to set constraints to get a multiline label in a static table view cell, but apparently this does not work for me, the label is still in one single line. I've set the numberOfLines property to 0 and also the height constraint to greater than or equal. And I'm setting the height for the cell correctly in tableView:heightForRowAtIndexPath. Please have a look at my screenshot to see the settings in IB.
In the comments above you mentioned you're not currently setting preferredMaxLayoutWidth. This property tells your label that it should lay out its text over the width of that property's value. In UILabel.h:
If nonzero, this is used when determining -intrinsicContentSize for multiline labels
In other words, if you don't set that, the label's intrinsic content size is whatever width the label needs to draw its text. If you set this property to the label's bounds, it will start drawing on the next line (or else it will cut the text off if numberOfLines is 0).
In your case, I would probably do that in tableView:willDisplayCell:forRowAtIndexPath:.
You can set the preferredMaxLayoutWidth in code, but when designing your user interface in storyboard, you still see a long one-line label that gets cut off at the edges. An alternative is to manually insert line breaks anywhere in your text right within the storyboard using Option-Return. You then just set the number of lines to more than your text will fit. Then select your label, hit Cmd-=. This will calculate the intrinsic content size for your label with the line breaks exactly where you want them to be.
Theoretically, I think setting the preferredMaxLayoutWidth is the more correct way to go about this, especially using Autolayout. However, I found it more practical to use the method I described above because it lets you see the layout at design time right in the storyboard, and you have total control of your line breaks. This usually works better for labels with text that don't change often. If you are dynamically changing the label text, setting preferredMaxLayoutWidth is the preferred way.

xcode 5 scrollview doesnt allow me to go all the way down with out it "bouncing"

Is there a way to have each label equal distances apart depending on how many lines are displaying per table cell. I can see all the data if I use both hands to tug the info up the screen but that isnt user friendly.
It sounds like you have UILabels in UITableViewCells? You may need to adjust the height of the cells via UITableViewDelegate's tableView:heightForRowAtIndexPath: message. In there, you probably want to calculate your height using boundingRectForSize:options:attributes:context: from NSString (iOS 7 and later). Make sure the numberOfLines property in your UILabel is 0 to adjust for the expanding height, and set the appropriate constraints.

How to increase space between text label and detail text label in table view cell?

How to increase space between text label and detail text label in table view cell?
I want to do this programmatically.
My updated answer)
I suspect you are using a standard UITableViewCell.
You should create your own subclassed UITableViewCell and put the labels on them directly with as much space as you want between them.
My original answer)
If you're doing this programatically (you're not clear if you're doing this as an Objective-C/Cocoa app), you can adjust row height via:
UITableViewDelegate's tableView:heightForRowAtIndexPath: method
or
UITableView's rowheight property
In Interface Builder (built into XCode 4.2 instead of being a separate app), you can also adjust the row height property in the Size inspector.
As far as I can understand, you want to increase the space between two cells and want to increase the width of separator line which is between the cells.
If you are looking for something readymade in form of some method or delegate, it is not available... you have to write your own trick for this one...!!
Best of luck...!
Sam

Resources