I tried both changing the separator style to None in IB and .none in code. In other tables that have a simple label in the row in other parts of my app, when I try to remove the separator style it works. But for some reason, in this UITableView it does not and I'm not sure why. Here is the screenshot from the simulator.
And here is a screenshot of the storyboard
In the storyboard, it's basically a UIView on the left with the initials, and then the three labels are embedded in two UIStackViews. There's a bottom horizontal UIStackView for grade and school, and then a vertical UIStackView for name and the bottom stack view. Do stack views prevent you from using separator style = none?
Try this :
self.tableView.separatorColor = [UIColor clearColor];
OR
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
Related
I've had some issues with my table view and the top cell. I'm using grouped Prototype Cells, and I've come across an issue with the spacing between the top bar and the first cell. As I've seen on other posts, I tried using 'adjust scroll insets' however, this created another problem, with the cell being hidden underneath the navigation bar. When I try changing the translucency of the navigation bar, the spacing returns. I've got some links to the images below.
When you use grouped cell, it's make space automatically in the header section. Try that;
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
if(section == 0)
return 5.0;
return 1.0;
}
It's because that you're using Grouped Style. people use this style to add their header for each group.
You should change the style to plain.
In xib, you should change the Style to Plain
Or do this programmaticlly when init the UITableView
UITableView *myTable = [[UITableView alloc] initWithFrame:CGRectZero
style:UITableViewStylePlain];
My first problem that i had was that my last UITableViewCell never had a separator which i wanted. I solved it using this code:
self.tableView.tableFooterView = [[UIView alloc] init];
Now that worked perfectly however with one problem. when i add that all my other views disappear. Here is a picture of before i use the one line of code above and after:
How can i fix this?
Set a zero height table footer view, like so:
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
Because the table thinks there is a footer to show, it doesn't display any cells beyond those you explicitly asked for.
Have you tried to use the viewForFooterInSection function?
Add a vertical spacing of 0 between your table view bottom and the view's top which is placed below it. And you need to set one view's height fixed either for UITableView or UIView. Add this code of line in viewDidLoad. It will display the separator also for last cell.
self.tableView.tableFooterView = [UIView new];
Screenshot:
May be this help
You have to set translucent property of tab bar controller
see this question to more reference...
iOS 7 TabBar Translucent issue
I have been using the following code for tableview
_comboBoxTableView = [[UITableView alloc] initWithFrame:CGRectMake(1, _selectContentLabel.frame.origin.y+_selectContentLabel.frame.size.height-1, frame.size.width+1, 48) style:UITableViewStylePlain];
_comboBoxTableView.layer.borderColor=[UIColor colorWithRed:226.0/255.0 green:226.0/255.0 blue:226.0/255.0 alpha:1].CGColor;
_comboBoxTableView.layer.cornerRadius = 10;
_comboBoxTableView.layer.borderWidth = 1.0f;
_comboBoxTableView.separatorColor = [UIColor colorWithRed:166.0/255.0 green:166.0/255.0 blue:166.0/255.0 alpha:1];
[_comboBoxTableView setSeparatorStyle:UITableViewCellSeparatorStyleSingleLine];
There is an unwanted white color on the left of each separator as shown below.
Is it a bug? I am running it with ios7.1. Any work around ?
It's not a bug. As of iOS 7, table views are capable of adjusting the insets of their separators. If you want an edge to edge separator, eliminate the insets:
if ([_comboBoxTableView respondsToSelector:#selector(separatorInset)]) { // In case running iOS < 7
_comboBoxTableView.separatorInset = UIEdgeInsetsZero;
}
More info in the UITableView documentation.
Just in case that you do not have time to fix this programatically, you can add subview patching the while line.
I do know that this not the properly solution, but works.
What worked for me: in Interface Builder, the tableview has a thing called Separator Inset. It's normally on Default (this seems to be 15).
You can switch it to Custom and replace the 15 with 0. No more weird lines.
In case if someone needs non-zero separator insets, those white lines are UITableCell which are not covered by the cell content view and separators. Just select UITableCell in the document outline (not the content view!) and set it the same background color as content view's background (or any color which you want).
I have a problem of the implementation of UITableViewCell's separator.
As you can see from the screenshot, there is a white gap visible before the separator, I think that is because I set the bg colour of the cell as light grey and also I put the inset of the separator as 53.
My first attempt was instead of using the separator, I was trying to draw the lines at the end of the cell by my self. But since on selection of the row the content of the row get updated, and there is a lot of issue regarding the calculation of the height of the cell.
So basically it is really hard for me to draw the line pixel precise at the end of the cell.
This left me the option to access the cell's separator's view, which currently not aware of any easy way, and fill the gap with my default background colour of the table.
My question is, how can I access the separator view
Or
Do I have any other alternatives to implement what I want?
Thank you very much.
UITableView doesn't provide APIs to access or modify the cells separator view directly. However, it has methods to change it's color, style, etc. Most of the times, though, the only solution for a custom separator is to draw it yourself, or better, to set the cell's backgroundView property to a simple view with a line subview or layer in it (a subview, although has some overhead, gives you the flexibility of autoresizing automatically using autoresizing masks or auto layout).
e.g.
UIView *backgroundView = [[UIView alloc] initWithFrame:cell.bounds];
UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(backgroundView.bounds) - 1, CGRectGetWidth(backgroundView.bounds), 1.0f];
[lineView setAutoresizingMask:(UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleTopMargin)];
[backgroundView addSubview:lineView];
cell.backgroundView = backgroundView;
Use this workaround:
Put UIImageView at bottom edge of cell and you can set image as per your requirement
STEP 1: Set divider as per image
STEP 2: Set Separator style to none
Since iOS 7 you can use this
cell.separatorInset = UIEdgeInsetsZero;
I've already used the following code to fix the separator issue:
if([tableView respondsToSelector:#selector(setSeparatorInset:)]) {
[tableView setSeparatorInset:UIEdgeInsetsZero];
}
However in iOS7 there is still a larger gap between the left and right edges of the UITableView and the cell.textLabel or detailTextLabel
I have custom UITableViewCells where I specify a position for a text label so this causes misalignment of the labels with the standard cells in either iOS 6 and 7.
Any ideas?
Try below solution which will remain consistent on ios 6,7
and you can put custom UILabel and connect to custom UITableViewCell class.
You can set divider by putting an UIImageView at the bottom edge of cell
and set Separator style to none from storyboard.
Are you using storyboard? If you are, it is best to do that from the storyboard. Select your UITableView Object from the UIViewController in the storyboard. Under "Attributes Inspector", find "Separator Inset", select "Custom" and make sure "Left" and "Right" are both 0.
Screen Shot:-
For UITableViewCell, the cell.textLabel and detailTextLabel's frame can only be modified in subclass of UITableViewCell. Just try this:
- (void)layoutSubviews{
[super layoutSubviews];
self.textLabel.frame = self.textLbFrame;
self.detailTextLbFrame = self.detailTextLabel.frame;
}
There are options when configuring the constraints in the Storyboard to make the constraint relative to margin. That option seems to be selected by default in the case of tableviews.
To fix: Select each horizontal constraint, select the Superview.Leading / Trailing and uncheck the Relative to margin.