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

  • SEARCH
  • Home
  • 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 7727451
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:27:45+00:00 2026-06-01T05:27:45+00:00

I’m pretty sure there is an easier way to do this that I’m missing

  • 0

I’m pretty sure there is an easier way to do this that I’m missing in all my reading…but this is driving me insane. I am very tired – and do apologize if this gets verbose.

I’m using an NSFetchedResultsController in my app – very standard issue – and it works. Two sections, ordered properly, etc. When a user taps a cell in the first section (the BOOL value of the property creating the two sections is reversed) – it moves to the second section (BOOL value flipped again) – and vice versa…again, works famously.

Here’s where my implementation gets a little funky. Eventually I want to support iAds – according to the HIG these should be placed at the bottom of the screen…the easiest way I found to do this is to put the UITableView inside a UIView, to avoid some logical reasons that escape me now – but that’s what I have – UIView with a UITableView.

I’m using Storyboards with prototype cells – two to be specific. One is used for adding content and acts as the delimiter between the two sections. The other is the default cell to display. When I register IBOutlets for this cell – it throws an exception (which is an issue, but I’m able to work around it). So, instead, what I’ve been doing is using cell.contentView.subviews to get to the elements I need to mess with:

    NSArray *cellSubViews = cell.contentView.subviews;
if ([cellSubViews count] == 3) {
    // editing accessory view
    cell.editingAccessoryType = UITableViewCellAccessoryDisclosureIndicator;

    // default background image view
    cell.backgroundView = self.defaultClockCellBackgroundImageView;

    // clock name label
    UILabel *clockNameLabel = [cellSubViews objectAtIndex:2];
    clockNameLabel.text = clock.name;
    clockNameLabel.textColor = (indexPath.section == 0 && ![clock.isAddClockCell boolValue])
    ? [UIColor whiteColor]
    : [UIColor lightTextColor];

    // view child button
    UIButton *viewChildButton = [cellSubViews objectAtIndex:0];
    UIImage *viewChildClocksButtonBackgroundImage;
    if (self.clockForFetch != nil) {
        //NSLog(@"child clocks list - N/A");
        viewChildClocksButtonBackgroundImage = [UIImage imageNamed:@"childcell_blank"];
        viewChildButton.enabled = NO;

    } else if ([clock.childClocks count] < 2) {
        //NSLog(@"add child button");
        viewChildClocksButtonBackgroundImage = [UIImage imageNamed:@"parentcell_addchild"];

    } else if (![clock.isRunning boolValue] 
               || [self totalChildClocksRunning:clock] < 1) {
        //NSLog(@"view child button");
        // children clocks cannot be running while parent is stopped; 
        // therefore, no need to actually check
        // this solves the "wait for cell animation to end" issue 
        // without the need for tableview reload data
        viewChildClocksButtonBackgroundImage = [UIImage imageNamed:@"parentcell_viewchild"];

    } else {
        //NSLog(@"view child running button");
        viewChildClocksButtonBackgroundImage = [UIImage imageNamed:@"parentcell_viewchild_running"];

    }
    [viewChildButton setImage:viewChildClocksButtonBackgroundImage forState:UIControlStateNormal];
    viewChildButton.hidden = NO;

    // view time entries list for clock
    UIButton *detailDisclosureButton = [cellSubViews objectAtIndex:1];
    UIImage *detailDisclosureButtonBackgroundImage = (self.clockForFetch == nil) 
    ? [UIImage imageNamed:@"parentcell_detaildisclosure"] 
    : [UIImage imageNamed:@"childcell_detaildisclosure"];
    [detailDisclosureButton setImage:detailDisclosureButtonBackgroundImage 
                            forState:UIControlStateNormal];
    detailDisclosureButton.hidden = NO;

    if (self.editing) {
        viewChildButton.hidden = YES;
        detailDisclosureButton.hidden = YES;
    }
}

Please note: prior to this method I was using a separate NIB with IBOutlets and could replicate the issue – just not as consistently.

Here is the table with three cells that move when tapped (Alpha, Beta, and Gamma)…ah, no images to new sorry – wish they could have told me that before I uploaded the images – enter ASCII art:

---------------
|    alpha    |
---------------
|    beta     |
---------------
|    gamma    |
---------------
| *delimiter* |
---------------

Here is the table after tapping the Alpha and Beta cells:

---------------
|    gamma    |
---------------
| *delimiter* |
---------------
|    beta     |
---------------
|    beta     |
---------------

However, if I tap on the custom detail disclosure button in the first cell labeled “Beta” (which should read Alpha), I get the correct object passed to the detail view:

--------------------------------------------
| < back    detail view for alpha     edit |
--------------------------------------------

So, the fetched results controller is being updated – it just doesn’t seem to be configuring things consistently when it talks to the table view. In the configure cell method above I’ve checked to see the names of the objects found in the controller – and they are also correct; i.e., the first beta cell (cell for row at index path 1,0) is Alpha – not Beta – even though the table view displays Beta.

I keep seeing mention of custom cells needing setNeedsDisplay and/or setNeedsLayout, but I don’t think I’m quite understanding that one – though I have tried putting it almost everywhere I could think of in the code. “NSFetchedResultsChangeMove” is what gets called when the user taps a cell – and I’ve tried a lot of the variations I’ve seen on the web (including here) to fix glitches that I thought were similar – to no avail.

I’m sure this construct will mature over time (as this is a first go) but, as I said, I encountered the same issue with a completely different construct (storyboards didn’t exist at the time) – and could still repeat the issue.

Any assistance would be greatly appreciated. And, if there is an answer on here for this exact same issue, I do apologize for the repeat.

  • 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-01T05:27:46+00:00Added an answer on June 1, 2026 at 5:27 am

    So, here’s what I did to solve the problem, it appears there are two possible contributors I could think of to the problem; hopefully this helps others if they find themselves in the same situation.

    1. I have two different prototype cells: the default one and the delimiter one. So, calling configure cell at index path directly may cause unexpected results. Therefore, anywhere I might have called configureCell atIndexPath, I just called cellForRowAtIndexPath instead. For example, in my fetched results controller update table methods, I altered everything to call cellForRowAtIndexPath instead (specifically the change update case – which is normally calling configure cell for row at index path:

      case NSFetchedResultsChangeUpdate:
          //NSLog(@"NSFetchedResultsChangeUpdate");
          [self.TJTableView cellForRowAtIndexPath:indexPath];
          break;
      
    2. Marching through the cell content view using subviews doesn’t seem to maintain itself, and it’s just not a very elegant way of doing things; so, I subclassed UITableViewCell with a custom cell per the instructional article here – http://bit.ly/oI2GGW – this way I could wire up the IBOutlets and reference the label and buttons directly in configure row at index path.

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

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.