First of all, these four maps. I want to implement the functionality. "One picture tells one copy to another Uiimageview"
Implementation code such as the following:
-(Ibaction) Pangesturetop: (Uilongpressgesturerecognizer *) longpress{uimenuitem * itempase = [[UIMenuItem alloc] InitWi thtitle:@ "Copy" Action: @selector (Copyimage)]; UIMenuItem * Itemtrans = [[UIMenuItem alloc] initwithtitle:@ "forward" Action: @selector (trans)]; UIMenuItem * Itemcollect = [[UIMenuItem alloc] initwithtitle:@ "Favorites" Action: @selector (collect)]; UIMenuItem * Itemjoin = [[UIMenuItem alloc] initwithtitle:@ "Add" Action: @selector (join)]; Uimenucontroller * Menucontroller = [Uimenucontroller Sharedmenucontroller]; [Menucontroller Setmenuitems: @[itempase,itemcollect,itemtrans,itemjoin]]; Cgpoint location = [longpress locationinview:[longpress view]; CGRect menulocation = CGRectMake (location.x, LOCATION.Y, 0, 0); [Menucontroller settargetrect:menulocation inview:[longpress view]; Menucontroller.arrowdirection = Uimenucontrollerarrowdown; [Menucontroller Setmenuvisible:yes animated:yes];} -(BOOL) canbecomefirstresponder{return YES; -(void) Copyimage{Uipasteboard * Pasterboard = [Uipasteboard pasteboardwithname:@ "Com.test.image" create:yes]; Pasterboard.image = [Self.topimgview image]; }-(ibaction) Pangesturebottom: (Uilongpressgesturerecognizer *) longpress{uimenuitem * itempase = [[UIMenuItem alloc] In itwithtitle:@ "Paste" Action: @selector (Pase)]; Uimenucontroller * Menucontroller = [Uimenucontroller Sharedmenucontroller]; [Menucontroller Setmenuitems: @[itempase]]; Cgpoint location = [longpress locationinview:[longpress view]; CGRect menulocation = CGRectMake (location.x, LOCATION.Y, 0, 0); [Menucontroller settargetrect:menulocation inview:[longpress view]; Menucontroller.arrowdirection = Uimenucontrollerarrowdown; [Menucontroller Setmenuvisible:yes animated:yes];} -(void) pase{Uipasteboard * Pasterboard = [Uipasteboard pasteboardwithname:@ "Com.test.image" create:no]; Self.bottomImgView.image = Pasterboard.image;}
When the operation. We need to turn the current uiviewcontroller into the first responders.
Copy is equivalent to copy a copy, increase I copied the picture, paste the image before the original image deleted. You can still go into the paste line.
Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.
Uimenucontroller,uipasteboard: Copy, paste detailed explanation