Drag and Drop UIView from a UIScrollView within a UIPopOverController to main UIViewController?
Okay, I'm having trouble getting this to work right. If anyone has successfully done this, and would be willing to share the code, I'd be forever in your debt!
Here's what I'm trying to do...
I have a main ViewController that I create my UIPopoverController from. This PopOverController contains a View that contains UIImageViews. These UIImageViews are programatically created in the viewDidLoad method of my PopOverController. I'm trying to get the UIView to pan from the popoverView within my PopOverController to the main ViewController that presents the PopOverController.
I got it to work kind of...
When a UIImageView is panned, I create a UIWindow and add that UIImageView as a subview to the new window. I can then pan the UIImageView outside the PopOverController, and in the Gesture ended state, remove the 开发者_Go百科UIImageView from the window I created and add it to the keyWindow. However, when I do this, the UIImageView is rotated counter clockwise, and the panning of that view/window does not start under the finger. I'm not sure why that's happening either. I'm sure both issues are part of the same main thing I'm missing.
I made a separate project with just the part I can't get to work right. If you're bored and feel up to the challenge in getting it to work.. Here is a link to download the project.
I haven't completely solved your problem, but I had a look at the project and I solved the problem (in your setting) of not having the rotated UIImageView initially appear at the correct position. You need to use the superview of the piece when you convert the rect, i.e., (line 72 in popupcontroller.m)
newPiece.frame = [piece.superview convertRect:piece.frame toView:dragAndDropWindow];
Hope this helps a bit.
精彩评论