For example:

```
<div style="background-color:black;width:20px;height:20px;" > </div>
<div style="background-color:red;width:20px;height:20px; margin:50px;" > </div>

```

<http://jsfiddle.net/TLLup/>

Here is two bars red and black. 
I want to stick black bar to red and black bar must follow to red if it changes coordinates and it doesn't matter what we are doing changes DOM or just using jquery function `$(element).position()`.
['https://Stackoverflow.com/questions/8034656', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/290082/']
I had a somewhat similar issue because I was performing my calculations in ViewDidLoad. I was able to work around the issue by creating a bool flag in the view's code and only performing the calculations in ViewDidAppear if the flag was not set (and, of course setting the flag so that the logic wasn't repeated each time).
On iOS 5 and up, sizeThatFits on a UITableView gives the correct result when called within the viewDidLayoutSubviews UIViewController method.