0

I seem to be having the exact opposite problem that pops up my question searches. I have a splitViewController that seems to be having a slow time updating its master view, after I call setNeedsDisplay. Eventually the update request gets drawn, but it is randomly between 5 to 150 seconds after the change should occur.

If I immediately rotate the iPad, the view changes are immediately reflected.

The layout is:

SVC - Detail VC
    \
     +-Navigation VC
                  \
                   MasterVC
                         +--UILabel (hidden/unhidden)
                         |
                         +--UIButton

All I want to do is hide/unhide a label in the MastVC when an action takes place in the MasterVC. On viewDidLoad, the label is hidden. When a button is pushed on the MasterVC, the label is unhidden and then things just don't go.

I have set everything under the sun to "setNeedsDisplay", but nothing makes it happen as fast as it should. If I even pushed all the setNeedsDisplay methods into dispatch_async(dispatch_get_main_queue(), ^{ ... }; there are no immediate results (not that I'm on a different thread, but it seemed like a good thing to try after reading similar questions).

I have made these calls from the SplitVC, the NavVC, the Master, each subVC, each subView, I even set up a Notification Center call from the Master to the SVC to have the SVC do the update specifically after the label was flagged as unhidden.

This all started to seem exceedingly off track, just to show/hide a simple label. Especially when all I have to do for the label show up properly is to just rotate the iPad.

As I said, the label eventually shows in the right spot, so it isn't off frame or opaque = 0 or something like that.

When I push the connect button, I make a call to Bluetooth Central Manager. Once the BCM connects to the device, I get a NC key/value that confirms connection. This triggers the label to be unhid.

-(void) receiveBCMNotification: (NSNotification *) notification {

NSDictionary *userInfo = notification.userInfo;

NSLog(@"got a BCM notice: %@",userInfo);
if ([[userInfo allKeys] containsObject:ddkBltCentralManagerStatusKey]) {
    if ([[userInfo valueForKey:ddkBltCentralManagerStatusKey] isEqualToString:ddvBltCentralMangerScanningStarted]) {
        [self.refreshAvailablePatches beginRefreshing];
    }
    if ([[userInfo valueForKey:ddkBltCentralManagerStatusKey] isEqualToString:ddvBltCentralMangerScanningEnded]) {
        [self.refreshAvailablePatches endRefreshing];
        [self.availablePatchesTableView reloadData];
    }
    if ([[userInfo valueForKey:ddkBltCentralManagerStatusKey] isEqualToString:ddvBltCentralMangerDeviceConnected]) {
        self.connectedToPatchVisual.hidden = NO;
        [self.view setNeedsDisplay];
        NSDictionary *newInfo = [NSDictionary dictionaryWithObject:ddvMasterSideViewNeedsDisplay forKey:ddkMasterSideViewNeedsDisplay];
       [[NSNotificationCenter defaultCenter] postNotificationName: ncMasterSideNotifications object:nil userInfo:newInfo];

    }
}

}
kejoki
  • 93
  • 9
  • Describe how you're setting the label to be unhidden. Edit your question to include the code that does that. – rob mayoff Apr 21 '17 at 21:55
  • Just to clarify: setting a view's `hidden` property to `NO` doesn't require you to call `setNeedsDisplay`, and if setting `hidden` to `NO` isn't making the label visible, then (as someone with substantial UIKit experience) I don't know why subsequently sending it `setNeedsDisplay` would help. – rob mayoff Apr 21 '17 at 21:56
  • I removed all of the setNeedsDisplay methods, and you are correct. Eventually the connectedToPatch Label does appear. So, the question still exists, why is there such a random lag for that item to appear, where, if I rotate the device, it immediately appears in the rotated layout... – kejoki Apr 21 '17 at 22:33
  • is `self.connectedToPatchVisual` a name of label or just a `Boolean` flag to show/hide button? – Ryan Apr 21 '17 at 22:33
  • @property (weak, nonatomic) IBOutlet UILabel *connectedToPatchVisual; – kejoki Apr 21 '17 at 22:48
  • 1
    Show the code that calls this `receiveBCMNotification:` or registers it as a callback. I suspect it's called off the main thread, and you only dispatched back to the main thread to call `setNeedsDisplay`. I think you didn't dispatch back to the main thread to set `hidden`. You must perform *all* `UIView` updates on the main thread. – rob mayoff Apr 22 '17 at 01:00
  • Yup this is it - Thanks – kejoki Apr 25 '17 at 16:20

0 Answers0