Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5931215
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:39:47+00:00 2026-05-22T14:39:47+00:00

I’m having a problem getting a UISearchDisplay’s text value to be set programatically on

  • 0

I’m having a problem getting a UISearchDisplay’s text value to be set programatically on load of the view by another view and my question is have I overcomplicated my problem and missed something or am I on the right track of thinking.

Here’s the situation: I have a UITabBarController as my root view, there are 2 tabs, both have a UINavigationController setup so I can push views as needed.

Tab 1 has a UITableViewController which is populated with a list of categories.

Tab 2 has a MapView in it’s main view but I have done a custom UINavigationItem view to put various buttons and a UISearchDisplay on the rightBarButtonitem area.

The mapview layout and custom navigation item are stored in the same nib as two separate view objects. In Tab 2’s viewDidLoad(), I initialise the rightBarButtonItem programatically with:

UIBarButtonItem *btnItem = [[UIBarButtonItem alloc] initWithCustomView:buttonBar];
self.navigationItem.rightBarButtonItem = btnItem;
[btnItem release];

Everything fires up, buttonBar is wired up to an IBOutlet as searchWhat and I can talk to this object from within the mapview’s controller class.

If the user is in Tab 1 and taps a cell, I want it to switch to Tab 2 and populate the searchWhat.text and then execute the search code as if someone had typed in the search themselves.

What i’m having trouble with is the order of load and populate on a view.

I can access the 2nd tab from the 1st without any problem and get it to appear with something like:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    NSLog(@"Quick Category cell tapped at row %d", indexPath.row);    
    self.tabBarController.selectedIndex = 1; // change to the search view controller
    //[self.tabBarController.selectedViewController viewDidAppear:YES];
    UINavigationController *nav = (UINavigationController *)self.tabBarController.selectedViewController;
    SearchViewController *srch = [nav.viewControllers objectAtIndex:0];
    //NSLog(@"%@", [srch description]);
    [srch queueSearchByType:kSearchTypeQuickCategories withData:[catList objectAtIndex:indexPath.row]];
    [srch viewDidAppear:YES];
}

Don’t worry about catList and SearchViewController, they exist and this bit works to switch tabs.

Here’s the problem though, if the user starts the application and selects an item in tab 1, tab 2 appears but the values of the search display text don’t get set – because viewDidLoad and viewDidAppear are called in another thread so the execution of queueSearchByType:withData: gets called while the view is still loading and setting up.

If the user selects tab 2 (therefore initialising the subview) and then selects tab 1 and an item, it can populate the search display text.

I can’t just change the order of the tabs so that tab2 is first and therefore loads it’s subviews to the navigation bar as the project specification is category search first.

Have I missed something very simple? What I need to do is wait for the second tab to fully appear before calling queueSearchByType:withData: – is there a way to do this?

At the moment, i’ve implemented a queue the search, check for a queue search approach, this seems to be a bit long winded.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T14:39:48+00:00Added an answer on May 22, 2026 at 2:39 pm

    Ok, I don’t like answering my own question but it appears my fears were right, basically if you want a UINavigationItem that is a custom view (ie, to put a search bar and various other buttons up on the nav controller) and be able to switch to and populate them from another tab on a tab bar controller, then you need to put the subview in it’s own class which is a subclass of UIViewController and then make delegation your friend (which it already is), i’ve provided an example in case anybody needs to repeat it which i’ve put on my blog HERE.

    http://www.jamesrbrindle.com/developer/ios-developer/howto-add-a-custom-uinavigationitem-to-a-uinavigationcontroller-with-delegation.htm

    If anyone disagrees and thinks this can be simpler, please let me know or rate this post

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have a reasonable size flat file database of text documents mostly saved in
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.