博客> UIMenuController
UIMenuController
2018-10-17 05:03 评论:0 阅读:949 沐晨_梦雪
ios UIMenuController

pragma mark -- cell的长按手势弹出menuController

-(void)longPress:(UILongPressGestureRecognizer *)recognizer { if (recognizer.state == UIGestureRecognizerStateBegan) {

    LGNoteCell *cell = (LGNoteCell *)recognizer.view;
    [cell becomeFirstResponder];

    UIMenuItem *modeify = [[UIMenuItem alloc]initWithTitle:@"修改" action:@selector(modeify:)];

    UIMenuItem *remove = [[UIMenuItem alloc]initWithTitle:@"删除" action:@selector(remove:)];

    UIMenuController *menu = [UIMenuController sharedMenuController];
    [menu setMenuItems:[NSArray arrayWithObjects:modeify,remove, nil]];

    [menu setTargetRect:cell.frame inView:cell.superview];
    [menu setMenuVisible:YES animated:YES];
}

} -(BOOL)canBecomeFirstResponder { return YES; } -(void)remove:(id)sender { } -(void)modeify:(id)sender { }

收藏
0
sina weixin mail 回到顶部