अपने HomeViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(yourUpdateMethodGoesHere:)
name:UIApplicationWillEnterForegroundNotification
object:nil];
}
// Don't forget to remove the observer in your dealloc method.
// Otherwise it will stay retained by the [NSNotificationCenter defaultCenter]...
- (void) dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
के लिए इस तरह की एक viewDidLoad विधि अपना ViewController एक tableViewController अपने भी सीधे पुनः लोड डेटा समारोह कह सकते है:
- (void)viewDidLoad
{
[super viewDidLoad];
[[NSNotificationCenter defaultCenter] addObserver:[self tableView]
selector:@selector(reloadData)
name:UIApplicationWillEnterForegroundNotification
object:nil];
}
- (void) dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self];
[super dealloc];
}
या आप एक ब्लॉक इस्तेमाल कर सकते हैं:
[[NSNotificationCenter defaultCenter] addObserverForName:UIApplicationWillEnterForegroundNotification
object:nil
queue:[NSOperationQueue mainQueue]
usingBlock:^(NSNotification *note) {
[[self tableView] reloadData];
}];
क्या आपके पास कुछ उदाहरण लिंक है क्योंकि मैंने कभी उपयोगकर्ता UIAplicationWillEnter नहीं किया है ForegroundNotification? – CroiOS
http://stackoverflow.com/questions/3535907/how-to-tell-when-controller-has-resumed-from-background – Cyrille
उत्कृष्ट, यह काम करता है। आपका बहुत बहुत धन्यवाद। – CroiOS