Reputation: 1
I have a button in view1. When I press that button, a second view, view2, is animated from the CGRect of that button. There is a category on the viewController side of the view2 where I can pass in the CGRect value of my button from view1. Furthermore, I store this rectValue in a property of view2. Now, when I close the view, I need the view to animate back to the same button. I do that by passing in another CGRect (the property that I saved on view2) to the same category. All of this works great.
The problem is - when I launch view2 from my button, and while I am in view2, change my device orientation, and then close it, the view still tries to go back to the original location of the button.
So I need to somehow, change the CGRect values according to change in orientation of view2. I could pass in the orientation of the view to the category, but I am still not able to change the rect values according to the new orientation.
Cannot apply autoResizeMaskTool to the button's rect, because the button is not present in the view2.
I looked into a method that almost solved the problem - convertRect:ToView: but didn't exactly do what I needed.(or maybe I just didn't know how to use that method properly)
Thank you in advance.
Upvotes: 0
Views: 261
Reputation: 9080
Rather than storing the rect as a property in view2, could you instead keep a weak reference to the button? That way, when you need to animate back to it, you can ask it for its frame at that point and you should get its new location if it has been moved due to rotation.
Upvotes: 1