Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7646093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:07:09+00:00 2026-05-31T10:07:09+00:00

In a ViewController I have the following: – (void)viewWillAppear:(BOOL)animated { DataObject *theDataObject = [self

  • 0

In a ViewController I have the following:

- (void)viewWillAppear:(BOOL)animated
{
    DataObject *theDataObject = [self theAppDataObject];
    NSDateFormatter *formatter = [[[NSDateFormatter alloc] init] autorelease];
    [formatter setDateFormat:@"MMM dd, yyyy HH:mm"];
    NSString *dateStr = [formatter stringFromDate:theDataObject.deadline];
    NSLog(@"Logged dateStr: %@", dateStr);
    [dateTimeLabel setText:dateStr];
    [super viewWillAppear:animated];
}

To clarify: dateTimeLabel IS wired up in the xib file. The viewWillAppear method is explicitly called from another ViewController, and is firing, like so:

- (IBAction)setDateTimeButtonClicked:(id)sender
{
    DataObject *theDataObject = [self theAppDataObject];

    theDataObject.deadline = [datePicker date];

    FirstMobileViewController *mobileVC = [[FirstMobileViewController alloc] init];
    [mobileVC viewWillAppear:YES];
    [mobileVC release];

    [UIView transitionWithView:self.view.superview 
                      duration:0.5 
                       options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionAllowAnimatedContent 
                    animations:^{[self.view removeFromSuperview];} 
                    completion:NULL];
}

The viewWillAppear method is firing — the dateStr is logged by NSLog appropriately when the superview is shown again. But the dateTimeLabel never updates. Obviously, commenting the NSLog line doesn’t make a difference.

The MADDENING thing is that even though NSLog logs dateStr just fine, if I change dateStr to, say, @"Yo!" or even to a locally initialized string, then dateTimeLabel will update, no problem.

What am I missing here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T10:07:10+00:00Added an answer on May 31, 2026 at 10:07 am

    You method to add a child view controller isn’t correct. Try with the following code (with your method, when you call ViewWillAppear, think that the view of the view controller isn’t yet initialized. (you san check that with a simple hack: adding mobileVC.view; just after the mobileVC initialization)

        - (IBAction)setDateTimeButtonClicked:(id)sender {
            DataObject *theDataObject = [self theAppDataObject];
    
            theDataObject.deadline = [datePicker date];
    
            FirstMobileViewController *mobileVC = [[FirstMobileViewController alloc] init];
            [self addChildViewController:mobileVC];
            UIView *superView = self.view.superview;
            mobileVC.view.frame = superView.bounds;
    
            [UIView transitionWithView:superview 
                              duration:0.5 
                               options:UIViewAnimationOptionTransitionFlipFromRight | UIViewAnimationOptionLayoutSubviews | UIViewAnimationOptionAllowAnimatedContent 
                            animations:^{[self.view removeFromSuperview];
                                          [superview addSubView:mobileVC.view]} 
                            completion:^(BOOL finished) {
                                          [mobileVC didMoveToParentViewController:self];
             }]; 
         }
    

    With this method, the viewWillAppear should be called automatically.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code in a UIViewController subclass: MyViewController *viewController = [[MyViewController alloc]
I have the following code: -(void)textFieldDidBeginEditing:(UITextField *)textField { CGRect textFieldRect = [self.view.window convertRect:textField.bounds fromView:textField];
I have an UIViewController having this method: - (void)viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; NSLog(@DISAPPEAR); lastKnownOrientation
I have following coding in my ViewDidLoad of ViewController - (void)viewDidLoad { [super viewDidLoad];
I have a viewcontroller like the following. But the touchsBegan doestnt get detected. Can
I have the following ViewController class #import <UIKit/UIKit.h> @interface SampleViewController : UIViewController { IBOutlet
I have the following code in my appDelegate: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions (NSDictionary *)launchOptions
I want to resize a TableView animated. I have the following structure TabBarController -->
I have application with following design: Table View that lists documents. And ViewController where
I have following lines of code in a program VisitWebsiteVC *visitWebSite = [[VisitWebsiteVC alloc]

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.