Reputation: 5228
I have a custom UIView containing UILabel as cell.accessoryView = containerView
. It was working fine until iOS 14 but as of iOS 15, the containerView
is changing its frame on tableView reload
. It is displaying properly on the first load but reloading causes the accessoryView
to change its frame. My code is
let notificationLabel = UILabel(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
let containerView = UIView(frame: CGRect(x: 0, y: 0, width: 30, height: 30))
containerView.clipsToBounds = true
containerView.backgroundColor = .clear
containerView.addSubview(notificationLabel!)
cell.accessoryView = containerView
I am changing the frame of the container based on text in UILabel in cellForRowAtIndexPath
.
It seems the frame code for containerView
is messing up. But this is working fine in iOS 14.
I guess there are some changes and the accessoryView
position is allowed to be changed in iOS 15.
Any suggestions to make it work without giving exact x-axis or y-axis in iOS 15?
Upvotes: 0
Views: 387
Reputation: 2188
I could not find a solution for this either. So I gave up on iOS 15's cell.accessoryView.
Instead, my cellForRowAtIndexPath handler calls:
[cell.contentView removeAllSubviews]
[cell.contentView addSubView:myCustomView]
Upvotes: 0
Reputation: 462
It's possible what your seeing is the extra "by default" padding added to the section header.
In your Viewdidload add
if (@available(iOS 15.0, *)) {
[self.tableViewName setSectionHeaderTopPadding:0.0f];
}
Upvotes: 0