zoukankan      html  css  js  c++  java
  • UIMenuController

    实现代码如下:

    01.-(IBAction)panGestureTop:(UILongPressGestureRecognizer *)longPress
    02.{
    03. 
    04.UIMenuItem * itemPase = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copyimage)];
    05.UIMenuItem * itemTrans = [[UIMenuItem alloc] initWithTitle:@"转发" action:@selector(trans)];
    06.UIMenuItem * itemCollect = [[UIMenuItem alloc] initWithTitle:@"收藏" action:@selector(collect)];
    07.UIMenuItem * itemJoin = [[UIMenuItem alloc] initWithTitle:@"加入" action:@selector(join)];
    08. 
    09.UIMenuController * menuController = [UIMenuController sharedMenuController];
    10.[menuController setMenuItems: @[itemPase,itemCollect,itemTrans,itemJoin]];
    11. 
    12.CGPoint location = [longPress locationInView:[longPress view]];
    13.CGRect menuLocation = CGRectMake(location.x, location.y, 00);
    14.[menuController setTargetRect:menuLocation inView:[longPress view]];
    15.menuController.arrowDirection = UIMenuControllerArrowDown;
    16. 
    17.[menuController setMenuVisible:YES animated:YES];
    18. 
    19.}
    20.-(BOOL)canBecomeFirstResponder
    21.{
    22.return YES;
    23.}
    24. 
    25.-(void)copyimage
    26.{
    27. 
    28.UIPasteboard * pasterBoard = [UIPasteboard pasteboardWithName:@"com.test.image" create:YES];
    29.pasterBoard.image = [self.topImgView image];
    30. 
    31.}
    32.-(IBAction)panGestureBottom:(UILongPressGestureRecognizer *)longPress
    33.{
    34.UIMenuItem * itemPase = [[UIMenuItem alloc] initWithTitle:@"粘贴" action:@selector(pase)];
    35. 
    36.UIMenuController * menuController = [UIMenuController sharedMenuController];
    37.[menuController setMenuItems: @[itemPase]];
    38. 
    39.CGPoint location = [longPress locationInView:[longPress view]];
    40.CGRect menuLocation = CGRectMake(location.x, location.y, 00);
    41.[menuController setTargetRect:menuLocation inView:[longPress view]];
    42.menuController.arrowDirection = UIMenuControllerArrowDown;
    43. 
    44.[menuController setMenuVisible:YES animated:YES];
    45. 
    46.}
    47.-(void)pase
    48.{
    49.UIPasteboard * pasterBoard = [UIPasteboard pasteboardWithName:@"com.test.image" create:NO];
    50.self.bottomImgView.image = pasterBoard.image;
    51. 
    52.}

     

  • 相关阅读:
    在插入一条记录后 取得自动增长ID
    hashtable,dictionary 从原理上说说有什么异同,哪个性能高一些
    单例模式
    聚簇索引与非聚簇索引的区别
    基于SQL SERVER2008的SCCM2007部署
    XML架构下的表结构设置主键
    IE6与IE7下一点样式的区别
    Session丢失原因与解决方案小结
    Python_如何去除字符串里的空格
    Python_让人脑阔疼的编码问题(转)+(整理)
  • 原文地址:https://www.cnblogs.com/wmwblog/p/5192915.html
Copyright © 2011-2022 走看看