قالب وردپرس درنا توس
Home / IOS Development / IOS – Other UIMenuController not hiding

IOS – Other UIMenuController not hiding



By pressing the cursor in a UITextView, a UIMenuController appears. Tapping Select causes relevant text to be selected and another UIMenuController with new options to display. If you tap anywhere else in the text viewer, the "other" UIMenuController gets to hide.

  Example Behavioral Behavior

I have a custom UIMenuTem that when tapping selects the current text line in a UITextView and then displays UIMenuController again for later actions, but the "other" UIMenuController does not hidden when you tap anywhere else in the view as expected.

  Example of unwanted behavior

Custom menu item action:

  - (void) selectLine: (id) sender {
NSString * strict = [[self textView] text];
NSRange area = [[self textView] selectedRange];
NSRange newRange = [string lineRangeForRange:range];

if ([[string substringWithRange:newRange] has Suffix: @ "n"]) {
newRange.length - = 1
; } [[self textView] setSelectedRange: newRange]; CGRect targetRect = [[self textView] firstRectForRange: [[self textView] selectedTextRange]]; UIMenuController * menuController = [UIMenuController sharedMenuController]; [menuController setTargetRect:targetRect inView:[self textView]]; [menuController setMenuVisible:YES animated:YES]; }


Source link