I have tried below code,It works to me.The point is before menu shows,add custom menu item, and then show the menu yourself.
-(void)viewDidLoad { [super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuWillShow) name:UIMenuControllerWillShowMenuNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuDidShow) name:UIMenuControllerDidShowMenuNotification object:nil];
}
-(void)menuDidShow{
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(menuWillShow) name:UIMenuControllerWillShowMenuNotification object:nil];
}
-(void)menuWillShow{
UIMenuItem *shareMenu = [[UIMenuItem alloc] initWithTitle:@"微博分享" action:@selector(shareToWeibo:)];
UIMenuController *menu = [UIMenuController sharedMenuController];
[menu setMenuItems:[NSArray arrayWithObjects:shareMenu, nil]];
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIMenuControllerWillShowMenuNotification object:nil];
[menu setTargetRect:selectedRect inView:self.view]; //must set,otherwise menu location never changed
[menu setMenuVisible:YES animated:YES];
}