UIMenuController使用

#pragma mark - UIMenuController

- (void)showDeleteMenu:(UIButton*)btnTag {

[selfbecomeFirstResponder];

CGRectbuttonFrame = btnTag.frame;

buttonFrame.size.height-=5;

UIMenuController*menuController = [UIMenuControllersharedMenuController];

UIMenuItem*deleteMenuItem = [[UIMenuItemalloc]initWithTitle:[NSBundlelocalString:@"delete"]action:@selector(clickBtnDelete)];

[menuControllersetMenuItems:[NSArrayarrayWithObject:deleteMenuItem]];

[menuControllersetTargetRect:buttonFrameinView:m_scrollView];

[menuControllersetMenuVisible:YESanimated:YES];

}

- (BOOL)canBecomeFirstResponder {

returnYES;

}

- (BOOL)canPerformAction:(SEL)action withSender:(id)sender {

if(action ==@selector(clickBtnDelete)) {

returnYES;

}

returnNO;//隐藏系统默认的菜单项

}

你可能感兴趣的:(UIMenuController使用)