The sequence of events of a UIVIEWCONTROLLER in IOS

While i was working on a one of my IOS app. i faced a small issue, and that issue was the load of data or refreshing data on all pages(5 pages). initially i thought i can resolve this issues using ViewDidload or ViewwillAppear but it was not.Because each page have different controls and contents linked with DateFormat of a common Database.

After a little google, someone suggest to use ViewDidAppear and it really worked for me.

Below are the sequence of Events

- (void)applicationWillEnterForeground:(UIApplication *)application
{
NSLog(@"app will enter foreground");
}

- (void)applicationDidBecomeActive:(UIApplication *)application
{
NSLog(@"app did become active");
}

// ViewController.m

- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"view did load");

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appDidBecomeActive:) name:UIApplicationDidBecomeActiveNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(appWillEnterForeground:) name:UIApplicationWillEnterForegroundNotification object:nil];
}

- (void)appDidBecomeActive:(NSNotification *)notification {
NSLog(@"did become active notification");
}

- (void)appWillEnterForeground:(NSNotification *)notification {
NSLog(@"will enter foreground notification");
}

- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
NSLog(@"view will appear");
}

- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
NSLog(@"view did appear");
}

tips & tricks

Join 7,719 other subscribers

interview questions


Algorithm Android Android Studio API APP Programming Apps blogging Browser CheatSheets Code Config CSS DATABASE dsa error Features HTML HTML5 IDE installation Interview Questions IOS iPhone javascript Mac objective-c OneDrive OS Placeholder Programming quicktips SDK SEO Settings SMO SQL swift swiftUI Teams Tips & Tricks Tools UI Web Wordpress Xcode


Archives

Leave a Reply

Your email address will not be published. Required fields are marked *

Discover more from CODE t!ps

Subscribe now to keep reading and get access to the full archive.

Continue reading