随便抄一点

(1)先设置下menu要显示的位置

- (void)setTargetRect:(CGRect)targetRect
               inView:(UIView *)targetView

Parameters
targetRect

A rectangle that defines the area that is to be the target of the menu commands.

targetView

The view in which targetRect appears

This target rectangle (targetRect) is usually the bounding rectangle of a selection. UIMenuController positions the editing menu above this rectangle; if there is not enough space for the menu there, it positions it below the rectangle. The menu’s pointer is placed at the center of the top or bottom of the target rectangle as appropriate. Note that if you make the width or height of the target rectangle zero, UIMenuController treats the target area as a line or point for positioning (for example, an insertion caret or a single point).

Once it is set, the target rectangle does not track the view; if the view moves (such as would happen in a scroll view), you must update the target rectangle accordingly.(需要办法更新下菜单的位置)


(2)显示菜单 - setMenuVisible:animated:

Before showing the menu, be sure to position it relative to the selection. See setTargetRect:inView: for details. If you do not set the target rect before displaying the menu, it appears at screen coordinates (0.0, 0.0).

(3)菜单箭头方向 typedef enum { UIMenuControllerArrowDefault, UIMenuControllerArrowUp, UIMenuControllerArrowDown, UIMenuControllerArrowLeft, UIMenuControllerArrowRight,} UIMenuControllerArrowDirection;

(4)几个回调通知

UIMenuControllerMenuFrameDidChangNotification

UIMenuControllerDidHideMenuNotification

UIMenuControllerWillHideMenuNotification

UIMenuControllerDidShowMenuNotification

UIMenuControllerWillShowMenuNotification
(5)自定义菜单 位置 menuIems[] = {UIMenuItem}

(6) Update

UIMenuControllerMenuFrameDidChangeNotification

Updating the Menu

  • Updates the appearance and enabled state of menu commands.

    Declaration

    OBJECTIVE-C

    - (void)update

    Discussion

    By default, UIMenuController calls this method just before the editing menu is made visible and when touches occur in the menu. As a result, a responder object in the application enables or disables menu commands depending on the context; for example, if the pasteboard holds no data of a compatible type, the Paste command would be disabled. You can call this method to force an update of the editing menu. You may also override this method to add any custom behavior.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值