قالب وردپرس درنا توس
Home / IOS Development / unavigation bar – iOS search field added after a small delay is not displayed in the navigation bar

unavigation bar – iOS search field added after a small delay is not displayed in the navigation bar



If I add a search field after a 0.1 second delay, it will not appear in the navigation bar. If I change the delay to 0.5 seconds, it will be displayed. Is this because when the delay is short, does it go under the push animation? How can I make it appear after a 0.1-second delay?

  - (void) viewDidLoad
{
[super viewDidLoad];
double delayInSeconds = .1;
dispatch_time_t popTime = dispatch_time (DISPATCH_TIME_NOW, (int64_t) (delayInSeconds * NSEC_PER_SEC));
dispatch_after (popTime, dispatch_get_main_queue (), ^ {
self.definesPresentationContext = YES;
UISearchController * searchController = [[UISearchController alloc] initWithSearchResultsController: null];
[self.navigationItem setSearchController:searchController];
[self.navigationItem setHidesSearchBarWhenScrolling:NO];
});
}


Source link