I want to change a UITableViewCell
's subview when it is being setup in the cellForRowAtIndexPath
with the following code:
cellSubView.center = CGPointZero
Printing out the frame's coordinates shows, that the frame updates successfully, however the view is still displayed in the position that was given in the interface builder.
Overriding the viewDidAppear
function with the following code would resolve this issue:
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
self.tableView.reloadData()
}
But this will result in blinking: the table view already did appear when I change one of its cells' subview's position.
How is it possible to change the frame before the view did appear?
If you used autoLayout check if it's creating the constraints automatically. If yes, then you can change the constants of these constraints instead. If you are not using autoLayout, call layoutIfNeeded and see if that changes anything. My bet though is on autoLayout creating constraints automatically.