This summary summarizes the use of the custom clipboard.
In fact, the custom clipboard is also very simple, it is nothing more than releasing the response time, using UIMenuController to customize the clipboard, and then the most critical implementation of the copy method you use to pull.
For convenience and practicality, I added a long-press event to the cell and read the code ---
UILongPressGestureRecognizer * recognizer = [[UILongPressGestureRecognizer alloc] initWithTarget: self action: @ selector (longPress :)];
[Cell addGestureRecognizer: recognizer];
Okay, the event is added, and the remaining click is to implement the custom clipboard. The Code is as follows:
-(Void) longPress :( UILongPressGestureRecognizer *) recognizer {
If (recognizer. state = UIGestureRecognizerStateBegan ){
CopyCell * cell = (CopyCell *) recognizer. view;
[Cell becomeFirstResponder];
UIMenuItem * flag = [[UIMenuItem alloc] initWithTitle: @ "Flag" action: @ selector (flag :)];
UIMenuItem * approve = [[UIMenuItem alloc] initWithTitle: @ "Approve" action: @ selector (approve :)];
UIMenuItem * deny = [[UIMenuItem alloc] initWithTitle: @ "Deny" action: @ selector (deny :)];
UIMenuController * menu = [UIMenuController sharedMenuController];
[Menu setMenuItems: [NSArray arrayWithObjects: flag, approve, deny, nil];
NSLog (@ "... % @", NSStringFromCGRect (cell. frame ));
[Menu setTargetRect: cell. frame inView: cell. superview];
[Menu setMenuVisible: YES animated: YES];
}
}
Through the above Code, the custom clipboard is successfully completed, run, you will suddenly find that, fuck, how did the Clipboard not come out, I guess you already think of why, because
-(BOOL) canBecomeFirstResponder {
Return YES;
}
There is no such important sentence. OK. The following is the method you want to use.
-(Void) flag :( id) sender {
NSLog (@ "Cell was flagged ");
}
-(Void) approve :( id) sender {
NSLog (@ "Cell was approved ");
}
-(Void) deny :( id) sender {
NSLog (@ "Cell was denied ");
}
Well, this is the basic clipboard customization. To make it more intuitive, the above three articles are similar to one of the following: