Change frame of UITableViewCell but it doesn't work
UITableViewCell *cell = [tableViewController.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:1 inSection:0]];
[cell setFrame:CGRectMake(cell.frame.origin.x, cell.frame.origin.y - 34, cell.frame.size.width, cell.frame.size.height)];
I want to change the frame of a table cell, the code works in some kind of ViewController, but some of them doesn't work. I want to know that there is something wrong with this.
source to share
You cannot have complete control over the cell border, especially at the beginning. The table view delegate is offered a table view cell, but then its position depends on the internal table view logic to properly position the cell inside the table view (which is a subclass of the scroll view). When the updated portion of the table view is updated, the cell position is reordered and the start of frame is updated. Therefore, until your code is wrong, it conflicts with some internal table rules that you cannot fully control, and therefore the results can be unpredictable.
If you want to see the visible effect of this change, you can move your frame change code to another part of the code, for example. inside
In such a case, you can, for example, touch the cell, call this code and change the frame of the cell, and you change it immediately. But as soon as you scroll a cell from the iPhone screen and then bring that cell back on the screen, you will notice that it reappears in its original position.
source to share