Add lines of text to subtitle of Xcode UITableView - objective-c

I am using master/detail template in Xcode. I can add text into the maintitle and the subtitle of the table view.
The subtitle only shows one line of text with ... at the end.
I understand that it is telling me that more text is available.
How would I have it give me 2 or maybe 3 lines of text before the ... I tried making the cell larger, but that had no affect.
I don't see any parameters that will increase the number of lines.
thanks

The default cell give you a label with just one line, if you want change it you will need to create your own custom UITableViewCell and add a label wit the number of lines you need:
Customizing UITableViewCells

Related

Word wrap position in UILabel

When working with a muti-line UILabel object, is there a way to know at which position in the text the line wrapping will occur?
For example if the text of my label is 20 words, the display will be different according to the size of the box provided. I would like to know when (character position) the display is going to the next line.

How can i achieve Multiline UILabel with NSLineBreakByTruncatingMiddle and sizeToFit in autolayout?

I have a two line UILabel. I want its line break mode NSLineBreakByTruncatingMiddle. The problem i am getting is if text is small enough to fit in one line, its showing it in middle of label instead of at top. I am using iOS6 and autolayout so sizeToFit is not working for me.
How can i achieve this? I want if text is small to fit one line it should be vertically top aligned. I have tried this, but its truncating and showing the text in one line only rather than two line.
You need to calculate the required size and update the frame of your label:
CGSize s = [myLabelString sizeWithFont:...
constrainedToSize:CGSizeMake(..., MAXFLOAT)
lineBreakMode:NSLineBreakByTruncatingMiddle];
With whatever font your label is using and its width.

How do I accommodate all the information in one table cell in my iphone application?

In my table cell I have long line of information and because of that I'm not able to show all the information properly. I tried to make the table cell's hight big but that didn't help.
below is the image of the table cell where you can not see the rest of the information.
Thanks
Mayur
You can take Custom cell and inside the same,take UILabel with the property of word wrap with Linebreakmode.Remember to take numberOfLines to 0. Hope that Helps you.
You Can Create a CustomCell inheriting UITableView class and set the size of the cell to the size of custom cell and to get multiple lines you can also set linebreakmode :
lblName.lineBreakMode = UILineBreakModeWordWrap;
lblName.numberOfLines = 2; //Specify Number Of Lines

UILabel object overlaps UITextfield in custom table cell after changing text property

I have specified a custom cell containing a label and a text field in a nib file.
When I change the text property of the label and adding three of those cells in a section of a table view it looks like this:
When I don't touch the text property and simply adding the cell out of the nib file "as is" it looks like this
Well there still remains the question why the textfields right edge moved, but that is not the main problem. Can somebody tell me how I have to configure the label to avoid that nasty behavior when changing the labels text?
Change the frame of your UILabels. Now it looks like they are about 280-300px wide. Change it to something less, 120 for example.
yourTextField.frame = CGRectMake(0, 0, 120, 30);
or some other numbers. Play with it.
Hope it helps
P.S. some code would be nice
Aaaah the great mysteries of autoresizingMask. Do it like this:
Resize your labels width and can always change label background to clear
yourLabel.backgroundColor=[UIColor clearColor];

How do you keep text from wrapping in an NSTableView using NSAttributedString

I have an NSTableView that has 2 columns, one for an icon and the other for two lines of text. In the second column, the text column, I have some larger text that is for the name of an item. Then I have a new line and some smaller text that describes the state of the item.
When the name becomes so large that it doesn't fit on one line it wraps (or when you shrink the window down so small that it causes the names to not fit on a single line).
row1===============
| image | some name |
| image | idle |
row2================
| image | some name really long name | <- this gets wrapped pushing 'idle' out of the view
| image | idle |
===================
My question is, how could I keep the text from wrapping and just have the NSTableView display a horizontal scroll-bar once the name is too large to fit?
Scrolling in Cocoa is implemented with the NSScrollView which is a view instead of a cell so if you really want to implement horizontal scrolling for table view cells I think you'd have to subclass the whole NSTableView and implement the feature there. My suggestion (without knowing the specifics of your situation, of course) is that you don't do that, though, since it's nonstandard behaviour and would probably entail quite a bit of work.
Truncate Instead of Wrap
If you're using a standard NSTextFieldCell, just select "Truncates" for its layout value in IB instead of "Wraps".
If you have a custom NSCell where you're doing your own drawing (I assume this is the case here), you should create an NSParagraphStyle, set its line break mode, add it as a value for the NSParagraphStyleAttributeName key in the NSAttributedString's text attributes dictionary.
An example:
NSMutableParagraphStyle *paragraphStyle = [[[NSMutableParagraphStyle alloc] init] autorelease];
[paragraphStyle setLineBreakMode:NSLineBreakByTruncatingTail];
[attributedStr
addAttribute:NSParagraphStyleAttributeName
value:paragraphStyle
range:NSMakeRange(0,[attributedStr length])];
Cell Expansion Frames
If you don't want to wrap your lines of text in the table view cells, the standard method of allowing the user to see the whole text is to use cell expansion frames which are enabled by default:
Cell expansion can occur when the mouse hovers over the specified cell and the cell contents are unable to be fully displayed within the cell.
If they're not working for some reason and you're using a custom NSCell subclass, make sure you implement -drawWithExpansionFrame:inView: and -expansionFrameWithFrame:inView: in your cell. Also make sure you're not returning NO in your NSTableViewDelegate for -tableView:shouldShowCellExpansionForTableColumn:row: (if you have one).
Adjust Width of Whole Table View?
If what you want to do is to adjust the width of a specific column (and thus the whole table view, possibly causing the enclosing scroll view's horizontal scroll bar to appear) such that the text its cells contain would never be truncated or wrapped, you can probably do that in your NSTableViewDelegate, for example, by calling -cellSize for each row's cell in that column and resizing the column to the largest value (you'll want to only do this when the values change, of course).