iosuinavigationitemuicontextmenuinteraction

Why UINavigationItem shows menu button?


I have UINavigationItem with UISearachController;

#warning - addded UISearchController
self.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.navigationItem.searchController = self.searchController;
self.navigationItem.hidesSearchBarWhenScrolling = NO;
if (@available(iOS 16.0, *)) {
    self.navigationItem.preferredSearchBarPlacement = UINavigationItemSearchBarPlacementInline;
    
}
self.searchController.searchBar.delegate = self;
self.searchController.searchResultsUpdater = self;
self.searchController.definesPresentationContext = YES;
self.searchController.obscuresBackgroundDuringPresentation = NO;
self.searchController.hidesNavigationBarDuringPresentation = NO;
self.searchController.searchBar.placeholder = @"Search";
self.searchController.searchBar.searchBarStyle = UISearchBarStyleProminent;
[self.searchController.searchBar sizeToFit];

When I tap on the search button in the navigation bar then I can see a search field and some button with three dots(it looks like UIContextMenu, and after tapping on this button in log, I see "[UILog] Called -[UIContextMenuInteraction updateVisibleMenuWithBlock:] while no context menu is visible. This won't do anything.")

enter image description here

Questions:

  1. Why can I see this in the navigation? (I don't add this)
  2. how can I remove this button from the navigation view

Solution

  • so this element is named "Overflow support button". (thanks @Mozz)

    If you add any item to navigationItem.rightBarButtonItems then you can see this "Overflow button" when open searchbar (self.navigationItem.preferredSearchBarPlacement = UINavigationItemSearchBarPlacementInline;)

    In my case I have reimplemented rightBarButtonItem and this allows me to omit the representation of "Overflow button"

    UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:self.modeButton];
    if (@available(iOS 16.0, *)) {
        UIBarButtonItemGroup *group = [[UIBarButtonItemGroup alloc] init];
        group.alwaysAvailable = YES;
        group.representativeItem = barButton;
        self.navigationItem.pinnedTrailingGroup = group;
    } else {
        self.navigationItem.rightBarButtonItem = barButton;
    }