I have a main view controller showing on the screen and a class (delegate) running in the background getting positions. When I get the result I call the delegate method in the view controller to update the label on the screen. I tried several ways but still no update to the screen.
Here is the method:
-(void) updateDisplay
{
NSLog(@"%@",myPosition.currentArea);
_area.text = [NSString stringWithFormat:@"area = %@",myPosition.currentShopArea];
//[self.view performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone:YES];
[self.view setNeedsDisplay];
//[self.view setNeedsLayout];
}
I check the console, it displays the correct area but on the screen still showing null. I tried all three ways (commented out above) but none of those update the screen.
You could try 2 things:
calling updateDisplay on the main thread:
[delegate performSelectorOnMainThread:@selector(updateDisplay) withObject:nil waitUntilDone:YES];
in the end, it is accessing UIKit, so better doing it right;
if that does not help, try with:
[_area setNeedsDisplay];
In this case also, if would be advisable to call the method on the main thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With