What are these mysterious borders in a TTableViewCell?
-
08-06-2021 - |
题
I have the following hierarchy in an IO application:
. TTTableViewController, with the following elements
.. @""
.. TTTableCaptionItem
.. @""
.. TTTableSubtitleItemCell
.. @""
.. TTTableTextItem
.. @""
.. (other cells)
.. TTTableViewItem
... TTTableViewController
This shows "mystery borders" around the embedded TTTableViewController which I can't seem to get rid of.
The embedded TableViewItem's initialization is completely vanilla:
@implementation DetailCommentsItemCell
- (id) initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:reuseIdentifier])
{
}
return self;
}
- (void)setObject:(id)object {
_item = object;
[self.contentView addSubview:[[object commentsViewController] tableView]];
}
(The "commentsViewController" is the embedded TTTableViewController)
Does anyone know what these borders are and how to get rid of them?
By request, here's the set up code for the table:
- (id)initWithFilter:(ObjectId)parameter_filter detailViewController:(DetailViewController *)dvp;
{
DDLogInfo(@"CommentsViewController::initWithFilter parameter_filter %llu",
parameter_filter);
if (self = [super initWithStyle:UITableViewStyleGrouped])
{
self.tableView.clipsToBounds = YES;
self.variableHeightRows = YES;
}
return self;
}
Update:
At @rishi's excellent suggest I added
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.backgroundView = nil;
This is much better but I still have an artifact. See below:
Another Update: I added the following code:
self.tableView.layer.borderColor = [[UIColor clearColor] CGColor];
self.tableView.layer.backgroundColor = [[UIColor clearColor] CGColor];
Now it looks like this:
It seems like it's the layer that is the culprit - but I can't get rid of the border - if that's what it is.
As an experiment, I set the border of the containing cell's layer to 2, and Red. Here's what I get, which tells me the mystery border is associated with the table, not it's surrounding cell:
This is ODD. I looked at it in a Retina display, and the "border" is actually the border of some object BEHIND the table.
FINAL UPDATE:
That artifact turned out to be the border of the table cell the inner TableViewItem was embedded in. The cells were offset due to an inset adjustment I'd made, but I'd failed to adjust the y origin correctly.
Thanks to everyone for their help!
解决方案
Use following code in initWithFilter
method-
self.tableView.backgroundColor = [UIColor clearColor];
self.tableView.backgroundView = nil;