Questions tagged [viewwillappear]

UIViewController instance method that notifies the view controller that its view is about to be added to a view hierarchy.

View controller subclasses typically override viewWillAppear to perform any tasks to customize the display of the view, based on the context in which the view is being displayed, as described in the documentation.

292 questions
1
vote
4 answers

how to determine which view loads on returning to foreground from the background in iOS?

I have an application which has more than one view. When I return to the foreground from the background, I want to determine which view I am in presently. How would I do that? [EDIT] I understand visibleViewController property of…
Namratha
  • 16,630
  • 27
  • 90
  • 125
1
vote
1 answer

Is `DispatchQueue.main.async` block in viewWillAppear always called after `viewDidLayoutSubviews`?

I wanted to change the collection view's contentOffset.x right after pushing VC. So I called collectionView.setContentOffset(~) in viewWillAppear. But It didn't work because of auto layout cycle. However, if I call collectionView.setContentOffset…
Nala
  • 37
  • 5
1
vote
2 answers

Detect when a specific view is opened from the background in SwiftUI?

If I have a SwiftUI view and I put it into the background (i.e. hit the home button once on the iPhone) and then reopen it again, I would like to trigger some action. My first thought was to make use of the .onAppear{} modifier, but, after some…
Evan
  • 1,892
  • 2
  • 19
  • 40
1
vote
1 answer

How to fix: UIView animations not restarting when returning to view controller

I have a view that starts animating when a ViewController first opens. It works fine on initial launch, but when returning to the view after leaving the animation does not restart. The views are embedded in a Navigation controller I tried placing…
NPanhuyzen
  • 23
  • 2
1
vote
1 answer

Hide navigation bar ios swift life cycle methods not called causing issues

I want to hide navigation bar in a particular view controller in my TabBarController Following is code in my first view controller of tabbar override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(true) …
amodkanthe
  • 4,345
  • 6
  • 36
  • 77
1
vote
2 answers

Loading of view in memory -- viewWillAppear method calls

How many times viewWillAppear method gets called in the lifetime of a view controller? I wanted to register for a notification only once when that view is loaded in memory and deregister it once it is unloaded. When I do it viewDidLoad method my…
Abhinav
  • 37,684
  • 43
  • 191
  • 309
1
vote
3 answers

Delete Rows from UITableView

Here is the code for my delete, it works fine but you have to open another tab and then click this tab again for the item to be removed. As this is not the normal UITableView you cannot just remove from array and then update table. so could someone…
user393273
  • 1,430
  • 5
  • 25
  • 48
1
vote
2 answers

How to present a UIViewController on viewWillAppear Event of a different UIViewConroller in iPhone SDK?

In my iPhone app, I have a requirement to present a new UIViewController on viewWillAppear event of a different UIViewController based on the condition. Actually I am trying to check whether user has logged in or not. I am trying something similar…
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
1
vote
0 answers

Swift iOS -How To Check If SelectedSegmentedIndex Is Visible in TabBarController?

I have a tabBarController with 2 tabs. On the 2nd tab, I have a segmentedControl with 2 segments. In the viewWillAppear of both segments, I have code that runs. What I notice is whenever I press the 2nd tab, the code from both segments run. Even if…
Lance Samaria
  • 17,576
  • 18
  • 108
  • 256
1
vote
1 answer

viewdidappear not called when adding subview to navigation controller

func showCustomViewController(vc : UIViewController,dummy : UIView,fromView1:UIViewController){ datePickerShown = true let fromView = fromView1.navigationController?.view var navTopConstraint : NSLayoutConstraint! …
1
vote
1 answer

viewWillAppear equivalent for earlier version of OSX 10.10

life cycle methods (viewDidLoad, viewWillAppear, viewDidAppear etc) are available since OSX 10.10 Yosemite. Then how to used viewWillAppear in OSX 10.8,10.9 is there any other options for Lower version OS.
1
vote
1 answer

iPhone view loaded many times... but never unloaded?

My iPhone app is based on a common "utility template" like Apple's own Weather app. I click on the info-button and it flips the screen around. I click on my done button... and it flips back. That part all seems to work ok. I've placed NSLog()…
Patricia
  • 289
  • 3
  • 6
1
vote
1 answer

Coding custom SplitViewController - when should I call viewWillAppear, viewDidAppear, etc...?

I'm writing my own SplitViewController from scratch (i.e. by subclassing UIViewController and not UISplitViewController). It has two sub-viewControllers (one for the left panel and one for the detail right panel), to which I need to send the…
monchote
  • 3,440
  • 2
  • 20
  • 20
1
vote
1 answer

How to trigger viewWillAppear when going back in the navigation controller hierarchy?

I've been trying various methods to trigger some code when returning to the first level of a UINavigationController, but none of the below work... // HomeViewController.m -(void)navigationController:(UINavigationController *)navigationController…
cannyboy
  • 24,180
  • 40
  • 146
  • 252
1
vote
0 answers

viewWillAppear is never called, till I load a modal view controller in the of the view, after that viewWillAppear is behaving as we expect!

I noticed that this problem discussed elsewhere, and I've tried a number of solutions such as adding: - (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController…
user458336
  • 35
  • 5