複数のカスタムメニュー項目を追加したときに、UIMenuControllerに「More...」ラベルが表示されないようにする簡単な方法があったようです。すべてのシステムメニュー項目を削除する必要がありました。まだコピー作業を行うための回避策もここにありました。別のセレクターを使用してカスタムコピーコマンドを実装し、canPerformAction:withSender:をオーバーライドして、システムコピーを表示しないようにする必要がありました。
-(BOOL)canPerformAction:(SEL)action withSender:(id)sender
{
if (action == @selector(copy:))
return NO;
else
// logic to show or hide other things
}
残念ながら、このメソッドは機能しなくなりました(少なくともUIWebViewサブクラスでは)。canPerformAction:withSender:は、copy:を除くすべてのシステムメニュー項目に対して呼び出されるため、結果として、システムコピーメニュー項目が常に表示されます。これは、複数のカスタムメニュー項目がある場合、それらは常に「詳細...」の背後に隠されていることを意味します。
それで、システムのコピーアイテムを実際に削除する方法、またはメニューアイテムが「もっと...」の後ろに隠れないようにする別の方法はありますか?
アップデート
これは、canPerformAction:withSenderをオーバーライドしたときに得られる出力です。「copy:」アクションに対してメソッドが呼び出されないことに注意してください。
cannot perform action cut: with sender <UIMenuController: 0x7227d30>.
cannot perform action select: with sender <UIMenuController: 0x7227d30>.
cannot perform action selectAll: with sender <UIMenuController: 0x7227d30>.
cannot perform action paste: with sender <UIMenuController: 0x7227d30>.
cannot perform action delete: with sender <UIMenuController: 0x7227d30>.
cannot perform action promptForReplace: with sender <UIMenuController: 0x7227d30>.
cannot perform action _showMoreItems: with sender <UIMenuController: 0x7227d30>.
cannot perform action _setRtoLTextDirection: with sender <UIMenuController: 0x7227d30>.
cannot perform action _setLtoRTextDirection: with sender <UIMenuController: 0x7227d30>.
can perform action customCopy: with sender <UIMenuController: 0x7227d30>.
can perform action custom1: with sender <UIMenuController: 0x7227d30>.
cannot perform action custom2: with sender <UIMenuController: 0x7227d30>.
can perform action custom3: with sender <UIMenuController: 0x7227d30>.
can perform action custom4: with sender <UIMenuController: 0x7227d30>.
cannot perform action cut: with sender <UIMenuController: 0x7227d30>.
cannot perform action select: with sender <UIMenuController: 0x7227d30>.
cannot perform action selectAll: with sender <UIMenuController: 0x7227d30>.
cannot perform action paste: with sender <UIMenuController: 0x7227d30>.
cannot perform action delete: with sender <UIMenuController: 0x7227d30>.
cannot perform action promptForReplace: with sender <UIMenuController: 0x7227d30>.
cannot perform action _showMoreItems: with sender <UIMenuController: 0x7227d30>.
cannot perform action _setRtoLTextDirection: with sender <UIMenuController: 0x7227d30>.
cannot perform action _setLtoRTextDirection: with sender <UIMenuController: 0x7227d30>.