Swift increasing the width of tableview cell.textlabel - xcode

I've tried adding a prototype cell and a label to it, among other approaches but can't seem to get there.
My table ends up displaying a couple of words followed by ... with most of the row empty.
Thanks!

Related

Xcode Interface Builder 9.1 Collection View Cells have too small "expected height"

Recently, I encountered a problem with the Interface Builder which I failed to solve. I'm using a UICollectionViewController and whenever I add a Cell it immediately shows a orange rectangle (indicating a auto-layout update). Updating the frame/cell doesn't change anything. The warning associated with the orange marking reads "Expected: height=Y, Actual: height=X" where Y is always exactly X-100. That is: When I set a custom cell height of 193, it says "Expected: height=93". This happens no matter which size I enter.
The problem with this is that I have many difficulties with the subviews and their constraints. For instance, if I add a subview with the constraint to keep the same height as the cell, it will be shown as 93 (the expected height), even though my cell should be 193. Layouting becomes impossible.
I tried adding a new cell, same issue. I tried removing every subview and re-adding them, nothing.
Any ideas are highly welcome.
Thank you very much!
Solution found ! (Xcode 9.2)
The bug seems to only happen when you try to embed the UICollectionViewController in a Container View in the storyboard. The workaround is to remove the segue while you set your constraints, and re-add the segue once your constraints are well set.
I also think that setting UICollectionViewController size as Freeform could be responsible of the bug. If so, try to set constraints before changing the size.
Hope this helps !
I'm not sure if this solved it, but the warning and issue disappeared once I did the following:
Select the CollectionViewController in Interface Builder and set the size to freeform and make the height larger, large enough to show all your template cells. (Plus: maybe refresh the views). That solved the issue for me.
In my case, I have added two collection view cell, withing collection view Controller.Only setting the view controller to free form wont help us. Need to update the size, to get rid of the warning.
updating collection view cell frames, wont help us. Warning will be continuously changing its length.
I tried to work without considering the warning, as I have set my collection view cell size programmatically and it does working as expected.
I think it's just a strange bug
I delete the collectionViewController in SB, then create a new one, the problem disappear
This is a common bug with Interface Builder. I don't know the exact cause, but I believe it's something to do with placing collection views inside arrangement views that do not have an exact size. I've seen it when putting them in scroll views, stack views and container views.
There is a simple fix, although I believe this to be a bug in IB that ought to be corrected by Apple rather than hacking around it. The solution (for me at least - your mileage may vary!) is to place the collection view inside an ordinary UIView and pin its edges to it, then place that parent view in the position that you wanted your collection view with all the constraints it required.
I usually found that there were actually no auto layout issues at run-time, which is why I believe this to be purely an Interface Builder bug.

Cutted text in NSTableView column

I'm playing a bit with NSTableView and CoreDate in Swift and all works almost ok but still can't fix an issue with cutted text in column's TableViewCell. It always shows ellipsis where text is loger than certain number of characters and I can't change it neither by setup in IB nor by changing column width and plaing with layout constraints.see attached screenshot
Any hint much appreciated, thanks.
Finally I found the solution and used code line below (cell is NSTableCellView)
cell.textField!.lineBreakMode = NSLineBreakMode.ByWordWrapping
plus addd constraints to cell text fields

NSTableView as a form - nextKeyView issue (or how to force load all rows)

Perhaps using an NSTableView as a form is a terrible idea, but I've got it working pretty well in every respect except that you can't tab from field to field.
I have a table with a label column and a field column. I also have an array that keeps track of each row in the table with its accompanying NSTextField control. The controls are set in the array as they are loaded during tableView(tableView: viewForTableColumn: row:).
After the tableview is drawn, I run through each control in the array and set its nextKeyView to the following control.
This works swell, BUT only for those controls which have been displayed on screen. Because the control isn't added until it's loaded, table rows which are off-screen aren't hooked up.
My current approach (which is awful) is to manually scroll the table several times in order to force everything to load, then set all the nextKeyViews. I haven't got it working very well yet, so I was hoping someone had a better idea. Force-loading all views, if it works, should be an OK solution, but there may be something smarter out there too.
I guess the answer is
table.scrollRowToVisible(<row>)
This will show the row you want to see.

Static UITableView not showing cells with subviews (UIButton, UISlider etc.) in Content View

I've run into a peculiar problem with Xcode. I have a custom UITableViewController that appears as a popover for a few settings in an iPad app. It's a static table view with just 3 cells in 2 sections. It looks fine in the Storyboard editor, but at runtime the cells with custom views (UILabels, UISlider, UIButton) do not show up at all, but those custom views do (in random places).
When I delete the custom elements from the cell or change the cell to anything but custom then they show up fine, even if the view (like basic for example) contains a label in its Content View. It's a lot clearer to see with the attached picture.
To solve this, I've created a completely empty cell below those with custom elements. It looks fine, but I can't interact with any elements. User Interaction is enabled for all elements, cells, and the entire table view. If you have any ideas how to solve that or how to get the cells working properly so I don't need the blank cell hack that'd be much appreciated!
I'm using Xcode 6 beta 7 on OS X Yosemite, programming in Swift.
Thanks in advance!
The question has been answered here Stack Overflow Setting up Auto Layout connections from the label to the Content View solves this issue.
It was a combination of the above link as well as this one that finally solved it.
I added the 4 constraints from each object (UIButton and UISlider) to all four sides of its cell's Content View (top, bottom, leading, trailing). Then, I had to check the "installed" checkbox for each constraint, which was not checked.
Thank you so much for your help, it's working great now!

UITableview bottom is cut off on iphone5

Let me preface this by saying this works perfectly on the iphone 4 - retina and regular.
I have a grouped table that has 4 sections. to set it up i use the dispatch_async stuff in viewWillAppear to grab the information from a server - and then call reloadTable when the server returns.
after the table has been reloaded with the correct information, when i try and scroll down i see more cells but it gives resistance as if i had already reached the end of the table even though there are 3 or 4 more table cells to show and bounces back.
there is one cell that has an image and some text that i use cell.addsubview to add some subviews to it in the cellForRowAtIndexPath function.
but all the other cell heights are normal (44)
I am using IB to have the grouped table view and don't set the frame,bounds, or anything with it in my code - just set the various tablecell heights using the correct function.
does anyone know why it would work perfectly in the iphone 4 (i can scroll down to the bottom and see all the cells) and not in the iphone 5?
Thank you.
I had autolayout checked in the Xib files.
To fix the problem i set self.view.frame.size.height to 568 in the top view controller (i was using a navigation conroller that loaded table views). once i did that, all the child views worked correctly.
I have same problem to fix like below optimized way
if your using autoLayout don't be hardcode just use constraints
i don't know how to use XIB but i always use like this
tableview.frame = cgrectMake(0,320,self.view.frame.size.width,self.view.frame.size.height-64);
64= nabvar height(44)+ top bar (22);
hope this help :)

Resources