My question is how can I implement a background when the tableview is empty like this:
http://pttrns.com/categories/35-empty-data
I tried to setup an UIImageView as backgroundView for the tableView but it appears always mixed with the empty cells.
Thank you in advance fo your help.
Regards,
Victor
You are going to have to turn off the cell separator and set your empty cells to a clear background color.
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
If you set a TableViewFooter to the UITableView, no cell will be drawn. This way, your image should be visible without mixing with any cells.
Alternatively, you can put the image in a special cell and use that cell as TableViewHeader that only gets added when you have no data.
Just cover the table view with a new view that says there's no data. Hide it when there is data.
set an UIImageView behind the table... then at viewwillappear.. if there is no rows for the table.. then set
self.tableView.hidden = YES;
hope it helps... GL HF
Related
I have a UITableView with 10 cells.
I've changed my UITableView's background color to red, but now there is a small red line between each cell (in addition to the separator line).
I need to disable this small gap between the cells that the background color won't be visible between the cells.
Screenshot:
Does anybody know how can I do this?
Thanks!
By going through your snap shot it is clear to me :
there is a separator which is a thin black line with custom offset set. That you can removed as mentioned in one of the answers.
other one is there is a red colour appearing in between cells. Please check is your tableView cell has clearcolor set. As you can see the last cell doesn't have red coloured line in bottom. Which i feel is you have a label over your cell which starts some pixel below the actual cell starts and hence you are able to see red coloured line over all cell excepts bottom of last cell.
In storyBoard select your tableView and then select "Attribute inspector"(at Right side) then Set "Seperator"->"None"
You can also do it by programatically -
UITableView property separatorStyle. Make sure the property is set to UITableViewCellSeparatorStyleNone and you're set.
example -
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
Try this in viewdidload:
self.tableview.backgroundcolor =[UIColor clearColor];
or
self.tableview.backgroundcolor =[UIColor whitecolor];
[self.tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
As you can see on screenshot, this is really annoying.
There are source code in screenshot :).
How can i remove it?
Thank you in advance.
You should look at the background color for your cell with the identifier "AlertSectionTypeCell." It looks like you have set the background color of your cell's content view instead of the background color of the cell itself.
I expect that the white line that you are seeing is the result of the cell's view's background color being set to "Default." Try:
let cell = tableView.dequeueReusableCellWithIdentifier("AlertSectionTypeCell") as! GMAlertsTypeTVCell
cell.backgroundColor = UIColor.clearColor()
I think the code you're looking for is...
tableView.separatorStyle = .None
That should remove the separator.
I will like add a white view under all cell in to the UITableView, because TableView background is Clear Color, and when Cell N is one or two under these is clear.
Screenshot
I will like under these cells view color will white.
P.D. Sorry, my english is so bad. =(
You mentioned above that there are UIView elements on your UITableView background so setting he background color of it would not work, correct?
You could try setting the background color of the UITableViewCell itself, and add any of your custom views as subviews on the cell.
cell.backgroundColor = [UIColor whiteColor];
Try to set up tableview's footer view, and make it with a white background.
Is there a way to draw lines between the cells in a UICollectionView? I'm not looking to add a border to each cell, that will result in drawing the lines only if there are any cells in the collection. What I'm looking for is something like UITableView's lines: they are there even if the table view has 0 cells.
I solved this by adding views to the collectionView.
I used the cell frames coordinates to determine where I wanted to draw.
However, there is probably a better way of doing this?
You can create a proper background for UITableView if your cells are of the same height. Draw the pattern image and apply it as a backgroundColor property:
UIImage *patternImage = [UIImage imageNamed:#"pattern.png"];
tableView.backgroundColor = [UIColor colorWithPatternImage:patternImage];
UPD:
Comment to this answer in incorrect. Background will scroll with tableView (or scrollView) content.
I want to make only one cell to be highlighted when it's selected.
I can't use UITableViewCellSelectionStyleNone because I want other cells to be selectable and can be highlighted in edit mode.
Every comment will be appreciated.
Thanks
I figured out how to do this
Just use next two lines in viewDidLoad and made last cell has very big (enough to cover entire cell) UIButton.
self.tableView.allowsSelection = NO;
self.tableView.allowsSelectionDuringEditing = YES;