Uimenucontroller,uipasteboard: Copy, paste detailed explanation

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.