IOS learning and ios learning routes

Source: Internet
Author: User

IOS learning and ios learning routes

Menu events include cut, copy, select all, and share... this demo only supports copy and share

 

1. Define field inheritance and UITextField

-(BOOL) canPerformAction :( SEL) action withSender :( id) sender {if (action = @ selector (copy :)) {return YES;} return NO;}-(void) copy :( id) sender {[self resignFirstResponder]; // persistence, the content of the copy exit program is still in [[UIPasteboard generalPasteboard] setPersistent: YES]; // The copied content [[UIPasteboard generalPasteboard] setValue: self. text forPasteboardType: [UIPasteboardTypeListString objectAtIndex: 0];}

2. ViewController Loading

Field = [[CCField alloc] initWithFrame: CGRectMake (100,200,100, 40)]; field. backgroundColor = [UIColor greenColor]; [self. view addSubview: field]; UIMenuItem * specify Item = [[UIMenuItem alloc] initWithTitle: @ "share" action: @ selector (click)]; UIMenuController * menu = [UIMenuController sharedMenuController]; [menu setMenuItems: [NSArray arrayWithObjects: Outline item, nil];

3. The implementation of sharing, for example, the preparation work is here

SendMessageToWXReq * sendReq = [[SendMessageToWXReq alloc] init]; // use the text message sendReq. bText = YES; // sent to a list. The default value is 0 sendReq. scene = 0; sendReq. text = field. text; // send the shared information [WXApi sendReq: sendReq]; NSLog (@ "213 ");

Complete the demo in githud. Click here to view

Related Article

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.