Search code examples
iosobjective-cuimenuitem

UIMenuItem selector not fired when selection caret is not fully visible


I am creating a UIMenuItem (and initialized with a UIMenuController) called which has the text "Share" (refer screenshot), and I am using this for selecting some text from the textView and sharing that content.

shareMenuItem=[[UIMenuItem alloc] initWithTitle:@"Share" action:@selector(socialShare:)];

When the textView is of height such that it is occupied in a single line, the selector for the UIMenuItems that I created are not triggering.

Here is the screenshot, of the problematic scenario. Clicking on "Share" doesn't fire its respective selector. Notice that the selection caret is not fully visible.

enter image description here

However, when the height of textview is such that it can occupy multiple lines, the selector is triggered when the selection carets are fully visible (like the screenshot) below.

enter image description here

I'm stuck with issue, so please give your suggestions to solve this problem.

Thanks


Solution

  • The only solution I had, was to increase the size of the cell by 5pts, so that the textview had enough space to show the caret fully. When the caret is shown fully, there is no problem.

    If anyone has an explanation to this problem, please feel free to comment on the question.