{"action":"opened","issue":{"url":"https://api.github.com/repos/lionheart/openradar-mirror/issues/13038","repository_url":"https://api.github.com/repos/lionheart/openradar-mirror","labels_url":"https://api.github.com/repos/lionheart/openradar-mirror/issues/13038/labels{/name}","comments_url":"https://api.github.com/repos/lionheart/openradar-mirror/issues/13038/comments","events_url":"https://api.github.com/repos/lionheart/openradar-mirror/issues/13038/events","html_url":"https://github.com/lionheart/openradar-mirror/issues/13038","id":148860537,"number":13038,"title":"15438558: Autolayout constraints not removed when a view is transplanted","user":{"login":"openradar-mirror","id":13605213,"avatar_url":"https://avatars.githubusercontent.com/u/13605213?v=3","gravatar_id":"","url":"https://api.github.com/users/openradar-mirror","html_url":"https://github.com/openradar-mirror","followers_url":"https://api.github.com/users/openradar-mirror/followers","following_url":"https://api.github.com/users/openradar-mirror/following{/other_user}","gists_url":"https://api.github.com/users/openradar-mirror/gists{/gist_id}","starred_url":"https://api.github.com/users/openradar-mirror/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openradar-mirror/subscriptions","organizations_url":"https://api.github.com/users/openradar-mirror/orgs","repos_url":"https://api.github.com/users/openradar-mirror/repos","events_url":"https://api.github.com/users/openradar-mirror/events{/privacy}","received_events_url":"https://api.github.com/users/openradar-mirror/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/lionheart/openradar-mirror/labels/classification:ui/usability","name":"classification:ui/usability","color":"f7c6c7"},{"url":"https://api.github.com/repos/lionheart/openradar-mirror/labels/reproducible:always","name":"reproducible:always","color":"5319e7"},{"url":"https://api.github.com/repos/lionheart/openradar-mirror/labels/status:open","name":"status:open","color":"009800"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/lionheart/openradar-mirror/milestones/6","html_url":"https://github.com/lionheart/openradar-mirror/milestones/OS%20X","labels_url":"https://api.github.com/repos/lionheart/openradar-mirror/milestones/6/labels","id":1237420,"number":6,"title":"OS X","description":null,"creator":{"login":"openradar-mirror","id":13605213,"avatar_url":"https://avatars.githubusercontent.com/u/13605213?v=3","gravatar_id":"","url":"https://api.github.com/users/openradar-mirror","html_url":"https://github.com/openradar-mirror","followers_url":"https://api.github.com/users/openradar-mirror/followers","following_url":"https://api.github.com/users/openradar-mirror/following{/other_user}","gists_url":"https://api.github.com/users/openradar-mirror/gists{/gist_id}","starred_url":"https://api.github.com/users/openradar-mirror/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/openradar-mirror/subscriptions","organizations_url":"https://api.github.com/users/openradar-mirror/orgs","repos_url":"https://api.github.com/users/openradar-mirror/repos","events_url":"https://api.github.com/users/openradar-mirror/events{/privacy}","received_events_url":"https://api.github.com/users/openradar-mirror/received_events","type":"User","site_admin":false},"open_issues":1217,"closed_issues":1,"state":"open","created_at":"2015-08-03T02:08:32Z","updated_at":"2016-04-16T15:02:03Z","due_on":null,"closed_at":null},"comments":0,"created_at":"2016-04-16T15:02:03Z","updated_at":"2016-04-16T15:02:03Z","closed_at":null,"body":"#### Description\n\nSummary:\r\nWhen a view is transplanted e.g. from a window's contentView to a new view, by using addSubview: to add it to the new view, the constraints on the view's former superview are left lingering. This leads a variety of a unexpected and hard to debug consequences.\r\n\r\nNote that the bug does not exhibit itself if the view is explicitly removed from the old superview. The bug in this case then is specifically that using -addSubview to move a view from one hierarchy to another does not cause the expected removal of constraints that you would see when calling -removeFromSuperview first.\r\n\r\nSteps to Reproduce:\r\nI'm attaching a sample project that demonstrates the bug. To see the bug quickly, open and run the project. Notice the views in the window are clipped and drawn in unappealing locations. Now change the #define WORKAROUND_BUG to 1 and run again. You'll see comments in the code explaining that the workaround is to explicilty remove the view from superview before transplanting it.\r\n\r\nThe gist of the steps for reproducing the bug in words is as follows:\r\n\r\n1. Create a nib-based project with autolayout enabled.\r\n2. Define constraints in the xib for a view \"view1\" within a window's  content view.\r\n3. At run time, transplant view1 into a new, custom view that is not associated (yet) with a window:\r\n\r\n[newView addSubview:view1]\r\n\r\n\r\nExpected Results:\r\nThe constraints on [window contentView] that pertained to view1 should be removed.\r\n\r\n\r\nActual Results:\r\nThe constraints pertaining to view1 are left on the window's contentView, and will cause issues particularly if view1, in its new configuration inside some other view hierarchy, is added back into the window.\r\n\r\n\r\nVersion:\r\n10.9 13A603\r\n\r\nNotes:\r\n\r\n\r\nConfiguration:\r\n\r\n\r\nAttachments:\r\n'DanglingConstraints.zip' was successfully uploaded.\n\n-\nProduct Version: 10.9 13A603\nCreated: 2013-11-11T18:42:37.822265\nOriginated: 2013-11-11T00:00:00\nOpen Radar Link: http://www.openradar.me/15438558"}}