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 7902281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:27:07+00:00 2026-06-03T09:27:07+00:00

I’m displaying a long list of items that I need to sort with 3

  • 0

I’m displaying a long list of items that I need to sort with 3 index (name, date, id). I then display the list with a UISegmentControl in self.navigationItem.titleView. The user can use that control to select which sort order he wants to display.
The user then have the option to filter that list based on some categories. I then have to sort again the list because it is possible that with the new filtered list, there will be only one name displayed so I don’t want to display the sort order by name. So I need to sort just to be able to reset the UISegmentControl.
Since the sort is taking a few seconds, I pushed it in another thread. Here is my code:

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context
{
if ([keyPath isEqualToString:@"value"]) {
    //The filter value has changed, so I have to redo the sort

        [[self navigationItem] setTitleView:NULL];
        [[self navigationItem] setTitle:@""];
        self.navigationItem.rightBarButtonItem.enabled = false;
        [self.tableView reloadData]; //I reload here because I want to display Loading... on my table (another var has been set before hands so the tableview will display that)

        dispatch_async(backgroundQueue, ^(void) {
            [self displayAfterFilterChanged];  
        });
}
}

-(void) displayAfterFilterChanged
{
displayState = DISPLAYRUNNING;
[self setupSort];  //<<< this is where the 3 sort index are setup based on the filter
dispatch_async(dispatch_get_main_queue(), ^(void) {  //<<< I call all the UI stuff in the main_queue. (remember that this method has been call from dispatch_async)
    [self.tableView reloadData]; //<< the table will display with the sorted and filtered data 
    self.navigationItem.rightBarButtonItem.enabled = true;
    if (!self.leSelecteur) { //<<< if I don't have a UISegmentControl I display a title text
        [[self navigationItem] setTitle:@"atitle"];
    } else { // I have a UISegmentControl, so I use it. 
        [[self navigationItem] setTitleView:self.leSelecteur];
        NSLog(@"before setneedsdisplay");
        [self.navigationItem.titleView setNeedsDisplay];
        NSLog(@"after setneedsdisplay");
    }
});
}

NOW, THE PROBLEM:
The table is redisplaying itself right away, the rightbarbuttonitem is enabled right away.
But the navigationItem titleView takes 5-10 secondes before it display itself.
Looks like it is skipping a display cycle and catch the next one.
Is there a way I could speed it up ?
I can see that “before setNeedsdisplay” and “after setneedsdisplay” are displayed on the log right away. But the actual refresh occurs 5-10 sec later.

  • 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-06-03T09:27:08+00:00Added an answer on June 3, 2026 at 9:27 am

    ok, got it. I was actually building my UISegmentControl in the thread. So I was playing with the UI not in the main thread (bad boy… slap, slap 😉 ). I moved all the code to create the control in the block called in the main thread, and voila, it worked. thank you all

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

Sidebar

Related Questions

In my XML file chapters tag has more chapter tag.i need to display chapters
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I

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.