I have a fairly complicated UIViewController with a custom UITableView instantiating on top of a Visual Effect & UIImageView. In order to keep the beautiful blur effect throughout the UITableView, I had to set the entire thing's background color (including UITableViewCells and viewForHeaderInSection) to UIColor.clearColor(). The obvious problem (that I can't solve) is that when I scroll up, the text of the UITableViewCell will scroll under the clear background of the viewForHeaderInSection and both text will overlap. Here's a screenshot.
Any thoughts on how I can prevent the UITableViewCell from scrolling under the viewForHeaderInSection? I was playing around with the UITableView's contentInsets but that changes the entire UITableView, not just the UITableViewCell sections. Thx in advance...
1) Select the tableview in storyboard.
2) Select attribute inspector.
3) Change the style from plain to grouped.
Related
I am trying to create a gap between my cells in a static UITableView. The UITableView has 3 sections, each containing 2 rows. I have tried
override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath: NSIndexPath) -> CGFloat {
return 15
}
but this method does not seem to work.
This might be a little bit of a hack but it has worked for me in the past.
Simply add a UIView to the UITableViewCell and set it as a different background colour to the UITableView.
If you make the UIView smaller than the UITableViewCell, you will be able to get the desired spacing just by adding constraints.
I hope I've understood the correctly
This isn't something that UITableView does by default. There isn't a simple way to add spacing between cells, that's generally something you'd accomplish by using a UICollectionView.
If you have to use a table view you can try adding the padding into a custom UITableViewCell itself, which will create the affect you're looking for. You could also try adding additional "spacer" cells that go in between your primary content cells.
I want to keep the footer of my UITableView float.
I did it correctly, but my problem is that, the footer doesn't show all, I have to scroll a little bit to see it, I don't know why.
look please, the footer just shows the top black, not the down black one:
Where I do have in the interface builder both top and bottom black bar
I add the footer easily like this:
override func tableView(tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
return self.footerView
}
The height of the footer is managed by the delegate method heightForFooterInSection. You need to pass the correct height of your footer in this method to show the footer completely.
Seems like height of footer in your implementation is cut off slightly. Make a try after increasing the height by 20 px.
A section footer view can "Float" only if your tableview style is "UITableViewStyle.Plain" , otherwise you need to implement a custom "Floating" View above your tableview by your self.
Set height of your tableview correctly. Your table view is going a few pixels down the screen. Setting tableview height will resolve the issue
The footer from the running app and from the storyboard looks different. The one from the app is rounded. Is there any chance there are two footers and you are using the wrong one?
Also you should provide some other information from your storyboard. Some images of your tableview properties for example. I think you are using autolayout. You can't get satisfying answers without these info.
Also you can check this answer for misplacement of your tableview. https://stackoverflow.com/a/27527905/697467
I want to load messages from my UITableView from the bottom up.
The blue is my UITableView, and the green is my first cell in a tableview with only one cell. The default, and what I have right now, is a normal UITableView where the green cell is at the top of the blue tableview.
I've researched this online, and the best solution I've found is to make several empty clear colored cells, but that doesn't satisfy the programmer in me.
What is the best way to do this?
Update: Yes, with enough cells I can just scroll to the bottom. But I am asking for only a few cells, while maintaining the UITableView's height.
Update 2: Can I create a custom UITableView to implement this? I don't want to change my UITableView into a UICollectionView.
I'm trying to print a UITableView, but a grey rectangle appears instead.
My UITableView is inside a UIView on my Storyboard and I'm using a custom UITableViewCell
Do you have any idea ?
Here's a gist of my code
Check the tableView background color and your cell background color on your storyboard.
I don't see anything wrong in your code.
I'm curious of how Youtube `s UITableViewCells are done, here is a screenshot:
Like you can see the cells are like squared and centred, how can I do that?
While you actually can use UICollectionView instead of a UITableView, this layout (YouTube App) can actually be achieved with UITableView as well.
You will need to create a custom UITableViewCell, that has few images and labels. When you create a custom UITableViewCell, you add items to the contentView property. You can then change the constraints or frame of the contentView property to achieve the effect.
Of course, there are more ways to achieve this layout, but I would follow this one:
Create a custom subclass of UITableViewCell.
Give UITableViewCell a clear background.
Give white background to the contentView UIView property of the created subclass.
Add constraints for margin between cells to contentView in UITableViewCell.
Design the layout of the cell in contentView.
It is basically not hard to create a design like this.
Use a UICollectionView instead of a UITableView
Cells are automatically centered, just create a square size.