Need assistance regarding custom UITableView and custom UITableViewCell - ios

This is screenshot of whatsapp, I have to create a tableview just like this one.
It has space on left side (Dont know top two cell are custom or default with right detail style).
Few cells in between have no separators.
How I am suppose to do same with my uitableview.

Start from iOS 7 left inset of UITalbeViewCell is default. Default value is 15, but you can change it.
This is not a few cells. This is One custom cell. I mean work+main+iPhone it is one cell.

Related

How to align labels in custom UITableViewCells?

I like to use the built-in cell styles (right detail, basic, subtitle) as much as possible, but some times I need custom controls, like a UISwitch or a UIStepper to be added to the cell, and I have to create my own custom cell styles on Storyboard.
Since iOS 13 and 14 suggests using the cell's imageView is a good idea to be used for adding icons to the rows, I use it on cells with built-in styles. It seems the image view doesn't have a fixed width and the table view adapts itself to the widest image.
What should I use to tie my UITextLabels on my custom cells to in order to make advantage of this behavior? When I tie the left side of the label to the left margin, then the label overlaps the imageView.

How to place UILabel exactly below UITableView?

I have UITableView with height of ≤500. Tableview data comes from database. Below UITableView, there is one label and two radio button. The problem is if data in the UITableView is less than its height, then it shows blank space between UITableView and those two radio button. I want to place those label and radio button exactly below tableview. How should I do this ?
This is how my tableview looks
If the table view's height does indeed vary depending on shown content, you could use UITableView's tableFooterView.
For a bit more context see this post for example.
Alternatively you could do this with basic auto-layout by tying your label and radio buttons (that you place as siblings of the table) vertically to the bottom of the table view.
I could also imagine that you may need a section footer. So you may want to have a look at that too.
If you want it to be scrollable, add it as the last row in your table view. You may also go with table view's footer.
If you want it to be sticky at the bottom in case of more rows, go with auto layouts. You may create outlet of table view's height constraint and adjust that accordingly depending on the number of rows. However, this approach is not appreciated.

How to set Table view cell to occupy entire screen?

I am working on a project to get custom news feeds from Bing news. I created a custom table view cell and populated various UI items in it. But I am having a hard time to make it occupy the entire screen, it starts from extreme left and ends on the right, leaving large gap from the right margin as show in the image. Can anyone help me out, how to correctly fix it with a detailed explanation of how constraints work in Table views and Tableview cells.
Here' what it looks like in the simulator
Remove previous constraints and add constraint to your UITableView like as shown in below image.
So you UITableView will have 0 margin from edges.
Create a UITableViewController. Just drag drop a TableViewCell into it. Add identifier for that cell and use it. By default it will occupy the whole screen.
In your case I guess you might have added constraints to UITableView. Here what you should do is pin your UITableView to Top,Bottom,Right & Left or make UITableView's width equal to SuperView.

UITableView with Horizontally wrapping cells

I am looking for how to, in Swift and Interface Builder, create a UITableView in Xcode where the table has a set width (example: padding to left and right edges of superview might be 8). In the table, I want cells to go across the first row. When a new cell can no longer fit in the first row I want it to go to the second row. When a new cell can no longer fit on the second row, I want it to go to the third row, etc. I only want the table to scroll vertically.
If anyone can point me to examples or documentation on this I would greatly appreciate it.
You are looking for UICollectionView.
http://www.raywenderlich.com/78550/beginning-ios-collection-views-swift-part-1
https://developer.apple.com/library/ios/documentation/UIKit/Reference/UICollectionView_class/

Kind of complicated custom UITableViewCell

I have a particular goal in mind here, searching for it is a little hard. I am trying to accomplish this (This is a photoshopped screenshot):
I have everything in this view working, except for the split row for the Company Name/ Beginning of the field row. The "Company Name" field is just a textfield, all I really want to do is shrink that neato cell background to just go behind the right side.
Create a custom table view cell that has two subviews: the text field on the left and a UITableViewCell on the right as a subview of the main table view cell. A UITableViewCell is just a UIView so you can actually add it as a subview of any view. The main table view cell will have it's background color set to transparent.
So totally complicated custom cell comes with a totally ridiculous solution. I built a view for the cell that has the one field...and another UITableView.
That second UITableView has the "Beginning of the field" text, and its cell gets the background, and I hide the background of the main cell.
I had to play around with the nested table's size and position to get the row to display properly, and make sure that the lines in the background don't shift when it hits the nested table, but it came out perfect
You could try setting the frame property of your cells backgroundView to cover only have your cell's width. Address Book handles complex forms like this with a nice look and feel--you might want to see what they've done there..
One approach would be to define a custom table view cell, set its background transparent and add the UITextField on the left and a UIButton on the right (customize it to look like your other cells), as in your screenshot.

Resources