Questions tagged [viewwillappear]

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

viewwillappear
Filter by
Sorted by
Tagged with
319 votes
7 answers
165k views

Why does viewWillAppear not get called when an app comes back from the background?

I'm writing an app and I need to change the view if the user is looking at the app while talking on the phone. I've implemented the following method: - (void)viewWillAppear:(BOOL)animated { [...
Philip Walton's user avatar
167 votes
4 answers
107k views

UIViewController viewDidLoad vs. viewWillAppear: What is the proper division of labor?

I have always been a bit unclear on the type of tasks that should be assigned to viewDidLoad vs. viewWillAppear: in a UIViewController subclass. e.g. I am doing an app where I have a ...
dugla's user avatar
  • 12.9k
43 votes
6 answers
38k views

Swift viewWillAppear not being called after dismissing view controller

I am presenting a view controller from a view controller called HomeController like so: let viewController = self.storyboard?.instantiateViewController(withIdentifier: "LoginController") as! ...
user979331's user avatar
  • 11.6k
39 votes
2 answers
27k views

viewWillAppear, viewDidAppear not being called, not firing

(This is both question and answer since it took quite a bit of digging to find the real answer.) Symptom: viewWillAppear, viewDidAppear were not being called in my UIViewController. Cause: ...
pschang's user avatar
  • 2,598
35 votes
3 answers
22k views

What similar functionality method (viewWillAppear) exists on UIView?

viewWillAppear is called on UIViewController when a view is about to be shown on screen. Is it possible to get similar callback on UIView?
Centurion's user avatar
  • 14.2k
34 votes
9 answers
39k views

UIViewController viewWillAppear not called when adding as subView

I have a UIViewController that I am loading from inside another view controller and then adding its view to a UIScrollView. self.statisticsController = [self.storyboard ...
Fogmeister's user avatar
  • 76.8k
27 votes
3 answers
11k views

Can i know in viewWillAppear that it was called after navigationController pop (back button)?

Say I have UIViewController A and B. User navigates from A to B with a push segue. Than user presses back button and comes to A. Now viewWillAppear of A is called. Can I know in the code here that I ...
adsurbum's user avatar
  • 3,147
25 votes
3 answers
19k views

Do I programmatically add SubViews in ViewDidAppear, ViewDidLoad, ViewWillAppear, the constructor?

I'm trying to figure out from Apple's sketchy documentation which method is the best place to be initializing and adding my Views controls to the controller's view. With winforms it's fairly ...
Chris S's user avatar
  • 65.1k
22 votes
6 answers
67k views

Swift - func viewWillAppear

I have a standard SingleViewApplication project. ViewController.swift import UIKit class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() // ...
Cristian C.'s user avatar
20 votes
2 answers
21k views

Guidelines for viewWillAppear, viewDidAppear, viewWillDisappear, viewDidDisappear

Are there any guidelines for using these methods in the right manner? In particular, I would like to know what type of code I could use inside them. For example, if I have to call a method that ...
Lorenzo B's user avatar
  • 33.4k
19 votes
4 answers
6k views

Navigationbar coloring in ViewWillAppear happens too late in iOS 10

I am facing a weird bug, that happens only on iOS 10. I have a application with several screens, and each screen colors the navigationBar in viewWillAppear. So when you go to the next screen, it will ...
Peterdk's user avatar
  • 15.8k
18 votes
3 answers
11k views

iOS: How to know if viewDidLoad got called?

Is there a BOOL or some other way of knowing if viewDidLoad: has been called? I need to change a view property every time my view has entered active, but if the view hasn't ever been loaded, I don't ...
kev's user avatar
  • 7,772
18 votes
8 answers
11k views

iOS 8: UITableViewCell detail text not correctly updating

tl;dr: Can I cause the detailTextLabel to have its size updated by the auto layout system in iOS on a value change? Has anyone else had issues with the detailText label within an UITableViewCell since ...
acidaris's user avatar
  • 190
17 votes
4 answers
7k views

In iOS 6, -[UITextField becomeFirstResponder] doesn't work in -viewWillAppear:

In iOS 5.1 and iOS 5.0 it works, but in iOS 6.0 the keyboard does not show. - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; UITextField *textField = self....
Jeffery Thomas's user avatar
11 votes
4 answers
7k views

Android SDK equivlent for viewWillAppear (iOS)?

Situation I have a fairly simple app with 2 "layouts" using SharedPreferences. Main.xml Settings.xml Main has a textView that uses getString from SharedPreferences. Also a button to open Settings. ...
David Todd Watson's user avatar
11 votes
1 answer
15k views

viewDidDisappear not called when use presentViewController

I have an UIViewController having this method: - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; NSLog(@"DISAPPEAR"); lastKnownOrientation = [self ...
Kyle_at_QP's user avatar
10 votes
4 answers
8k views

viewWillAppear in viewcontrollers of a tabbar

In my tab-bar I have four viewcontrollers, and what happens in one can affect the view of the other, so I may need to reload some elements in the viewcontroller when it becomes visible. Normally I'd ...
niklassaers's user avatar
  • 8,692
10 votes
2 answers
1k views

In IOS 4.x or lower, viewDidAppear method is not getting called while adding subview to a view, why?

In iOS 4.x or lower, viewDidAppear and viewWillAppear, viewDidDisappear and viewWillDisappear, such ViewController's delegate methods are not getting called. The same methods work fine with the iOS 5....
Mrunal's user avatar
  • 14.1k
9 votes
7 answers
17k views

iOS routing viewDidAppear to child view controllers?

I'm adding a child view controller to a parent view controller, and everything works as expected, except that child view controller isn't having its usual callbacks triggered. eg, things like ...
pachun's user avatar
  • 920
9 votes
2 answers
12k views

ViewWillAppear on UITableViewCell?

Is there any way to perform something like ViewWillAppear on UITableViewCell? UITableViewDelegate methods (like willDisplayCell) only works when cells appear by scrolling. In my situation, I need to ...
Bigair's user avatar
  • 1,552
9 votes
2 answers
6k views

When exactly should I call [super viewWillAppear:] and when not?

I have always thought that calling [super viewWillAppear:animated] is mandatory. But today I came across a piece of code from Apple's example application called CoreDataBooks and here's viewWillAppear:...
Andrey Chernukha's user avatar
7 votes
2 answers
754 views

UIStackView on TitleView Spacing issue after iOS 16

I have an UIStackView set up on the title view of the navigation bar in my app. It simply shows the icon of the app to the left of the title. In iOS 15 and earlier, this displayed fine. Right now, ...
user717452's user avatar
7 votes
5 answers
10k views

Problems with UINavigationController inside of UITabBarController, viewWillAppear not called

As an overview, I'm having issues with a UINavigationController inside of a UITabBarController calling viewWillAppear whenever a view is popped from the stack. From the delegate, a ...
Dandy's user avatar
  • 1,223
7 votes
3 answers
2k views

iPad viewWillAppear and presentModalViewController problems

In the iPhone, I have a tableview, and touching the cells, I have one method calling presentModalViewController, and opening another view, with email and this kind of stuff. When the user press the ...
Wak's user avatar
  • 71
6 votes
5 answers
19k views

About viewController's "viewDidLoad" and "viewWillAppear" methods

I've got a question regarding the two mentioned methods, since in my tests I don´t make clear the order they are called. I thought that, firstly, viewDidLoad is called when the viewController is ...
AppsDev's user avatar
  • 12.4k
6 votes
3 answers
4k views

Determine viewWillAppear from Popped UINavigationController or UITabBarController

I am unable to find a way to distinguish between popping from the Nav controller stack and entering the view controller from the UITabBarController. I want to call a method in ViewWillAppear only ...
DogCoffee's user avatar
  • 19.9k
6 votes
2 answers
1k views

iOS 9 changed view load behaviour

I have noticed a change in how iOS 9 loads/displays views compared to previous versions of iOS. Here's an output of self.view.frame in iOS 8.4 viewDidLoad {{0, 0}, {320, 504}} viewWillAppear {{0, 64},...
artooras's user avatar
  • 6,525
6 votes
2 answers
3k views

Determine the first time a UIViewController appears

Before resorting to custom flags I wanted to check this with you people. Is there a built-in way to determine in viewWillAppear: or viewWillDisappear: whether the UIViewController is 'newly pushed' ...
epologee's user avatar
  • 11.3k
5 votes
2 answers
4k views

When to put into viewWillAppear and when to put into viewDidLoad?

I get used to put either of viewWillAppear and viewDidLoad, it's OK until know. However I'm thinking there should be some rules that guide when to put into viewWillAppear and when to put into ...
LiangWang's user avatar
  • 8,368
5 votes
1 answer
2k views

Different subview layouts in viewDidLoad and viewWillAppear [duplicate]

Possible Duplicate: UIViewController returns invalid frame? While debugging i've noticed that in viewDidLoad call my view frame is origin=(x=0, y=20) size=(width=320, height=460) which is not ...
peetonn's user avatar
  • 2,972
5 votes
3 answers
5k views

popViewController / viewWillAppear not animated in iOS 5

I wasn't lucky with searching for this, so here we go ;) I have a UIViewController with a custom UINavigationBar which pushes another UIViewController as subview. Everything works fine except when I ...
Hannes's user avatar
  • 3,782
5 votes
2 answers
4k views

ViewDidAppear/ViewWillAppear not being called

I have a ViewController that adds to other subviews which have subclassed uiviewControllers so Its like this: mainViewController | v---------v subVC1 subVC2 And neither subVC1 or subVC2 ...
Jonathan.'s user avatar
  • 54.9k
5 votes
0 answers
358 views

tvOS searchController viewWillAppear not being called when navigating back

So I followed the instructions for the recommended way of adding a search view controller. Basically let resultsController = storyboard.instantiateViewControllerWithIdentifier(...
Programmer Unextraordinair's user avatar
4 votes
3 answers
5k views

Wrong value for statusBarOrientation on viewWillAppear

I need to change the image background of a View depending on the orientation. For this, I am using the statusBarOrientation approach in viewWillAppear: - (void)viewWillAppear:(BOOL)animated { [...
MRD's user avatar
  • 7,156
4 votes
2 answers
6k views

iOS - Loop through Cells and retrieve data

Sorry I'm pretty new to iOS dev. I have a UITableView setup from cells being pulled from a single XiB nib. I've created a on/off switch in the nib, and I am trying to save the state of the switch ...
Romes's user avatar
  • 3,088
4 votes
1 answer
4k views

Changing NSLayoutContraint constant in viewDidLoad or viewWillAppear don't works

I am trying to do something like this: - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; NSLog(@"%@", self.tableViewHeight); self.tableViewHeight.constant = 0; ...
k06a's user avatar
  • 18.2k
4 votes
0 answers
340 views

Changing the key window does not call view will/did dis/appear

When I change the key window, the rootViewController(s) do not receive view will/did appear/disappear. SplashViewController *screenLockViewController = [[SplashViewController alloc] ...
Octav's user avatar
  • 473
4 votes
1 answer
3k views

viewwillappear and viewdidappear not called

this question is very frequent, but I am not able to solve it with any answers available. I am working on iOS 5.1. My navigation controller is one tab amongst tab bar view controllers. There's a ...
Nikita P's user avatar
  • 4,226
3 votes
2 answers
7k views

Xamarin IOS hide bar back button

I am trying to hide the back button from my navigationcontroller on a certain view(using storyboard) I tried to hide the bar back button overriding the ViewWillAppear, but it does not seem to happen. ...
Emil Elkjær's user avatar
3 votes
3 answers
7k views

Is it a MUST for viewWillAppear to have [super viewWillAppear] method as well

I placed my code for iAd/AdMob ads in... -(void)viewWillAppear:(BOOL)animated{} Ads work perfectly fine the way I have them now on all iOS devices. When I connected my iPhone to Xcode and clicked on ...
Jet's user avatar
  • 575
3 votes
3 answers
3k views

How to avoid viewWillAppear initially calling

I want to know something aboutViewWillAppear.I have a viewwillappar method for data refreshing. What I want to do is when this viewcontroller push from the previous one this refreshing should not be ...
user2889249's user avatar
3 votes
2 answers
1k views

Swift viewWillAppear not being called first time usingTabBarController

So i have a tab bar controller and when I select into the second tab it brings me to a table view controller. I have it setup so that when the viewWillAppear it animates the cells in. The problem I am ...
Dallas's user avatar
  • 1,806
3 votes
3 answers
2k views

Is it necessary to call super in viewWillAppear?

I am trying to understand the scenario of the method calls to view did/will appear and disappear. What I did is selecting the table cell (higlights in grey) , go to detail view and go back and ...
Teja Nandamuri's user avatar
3 votes
2 answers
2k views

iOS 5.0 view life-cycle issue

I'm facing strange behaviour of my custom view controller subclasses on iOS 5.0. I'm not using standart navigation controllers etc. in my iPad application, but I'm presenting all view controllers ...
user999445's user avatar
3 votes
1 answer
1k views

Why does adding subview in viewDidLoad doesn't work

I was trying to add UIToolBar into a UIWebView but whenever I insert this code inside viewDidLoad UIToolBar doesn't show up, however when this is done in viewWillAppear, it works. Can someone please ...
user3526002's user avatar
3 votes
2 answers
1k views

viewWillAppear and UIApplicationDidBecomeActiveNotification

I am using the UIApplicationDidBecomeActiveNotification to refresh my tableview when the app becomes active. My problem is that in my ViewWillAppear, I am also calling a method to refresh this table'...
edhnb's user avatar
  • 2,162
3 votes
2 answers
4k views

Why showing and hiding view from viewWillAppear or viewDidAppear doesn't work

I recently converted an app from modal viewControllers to TabBarController and there is some code that used to work fine before the conversion but now I'm having a hard time making it work in the ...
fs_tigre's user avatar
  • 11k
3 votes
1 answer
4k views

Navigationbar not showing on pushing view controller

I have working on navigation base application. my problem is that when i am push other view controller into navigation controller .view controller viewWillAppear is not called. TestCategoryHistory *...
kEvin's user avatar
  • 411
3 votes
2 answers
2k views

How to stop viewWillAppear from completing until a function has finished

I'm pretty new to IOS Application Development. I'm trying to stop viewWillAppear from finishing until after my function has finished working. How do I do that? Here's viewWillAppear: override func ...
Alex's user avatar
  • 141
3 votes
3 answers
1k views

UINavigationBar disappears iOS7

I have some wierd bug with UINavigationBar. Sometimes it just disappears (actually if you move view to the half of screen, and then just release it) Video example In the first ViewController's ...
wiruzx's user avatar
  • 491

1
2 3 4 5 6