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 7679663
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:55:47+00:00 2026-05-31T17:55:47+00:00

i have a problem, i want set text of a UILabel or UItextView or

  • 0

i have a problem, i want set text of a UILabel or UItextView or another IBOUTLET objects,but i can do it only in the viewwillappear and viewdidload method, if i set text in another method in the code don’t change nothing, here is an example:

i have a method that retrieve string from another class, and then i want set this string in my uilabel:

- (void)setDetailItem:(id)newDetailItem
{

if (detailItem != newDetailItem) {
    NSLog(@"SetDetailItem");
    [detailItem release]; 
    detailItem = [newDetailItem retain]; 
    detailString = [[FindStringClass alloc] init];
    // Update the view.

    detailItem = [detailString searchStringFor:detailItem.name];

    if (detailItem) {
        //
        NSLog(@"setDetail: %@",detailItem.stringName);
        [self configureView];
    }

  }
 }

  - (void)configureView {

NSLog(@"configure view: %@",detailItem.stringName);
mySerialTitle.text = detailItem.stringName;
}

the NSLog work, and i can see my string in the console, but the text in view don’t change, instead if i set a simple text in the ViewWillAppear or viewDidLoad method work, so the connection with the IBOOutlets are right, like this:

- (void)viewDidLoad
{
mySerialTitle.text = @"CIAO";
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}

This is the call function where i call the setDeatItem from another view:

  self.searchResultViewController.detailItem =    [myArray objectAtIndex:[indexPath row]];    
  [self.navigationController pushViewController:self.searchResultViewController animated:YES];

anyone can help me?

EDIT:
This is the NSLog where the method are called:

2012-03-19 12:51:02.617 TestApp[292:b603] SetDetailItem
2012-03-19 12:51:06.161 TestApp[292:b603] setDetail: Chicken
2012-03-19 12:51:06.162 TestApp[292:b603] configure view: Chicken
2012-03-19 12:51:06.175 TestApp[292:b603] View DidLoad

i call the searchviewcontroller view from a Tableviewcontroller i press on a row and then call the new view and pass the attribute.

  • 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-31T17:55:49+00:00Added an answer on May 31, 2026 at 5:55 pm

    viewDidLoad is called after the view is loaded into memory. See viewDidLoad in the apple docs. After the view is loaded into memory and right before it appears, viewWillAppear is called.

    You cannot change the properties of the view before it is loaded. So, examine your code paths (and maybe even log out in those methods and the viewDidLoad and viewWillAppear method) and see if you’re setting those properties before viewDidLoad is called (log output will make it easy to see).

    From viewDidLoad docs:

    This method is called after the view controller has loaded its view
    hierarchy into memory. This method is called regardless of whether the
    view hierarchy was loaded from a nib file or created programmatically
    in the loadView method. You usually override this method to perform
    additional initialization on views that were loaded from nib files.

    You’re log statements that you added makes it clear that you are manipulating the views before they are loaded. As you can see, setDetail is called before viewDidLoad.

    2012-03-19 12:51:02.617 TestApp[292:b603] SetDetailItem
    2012-03-19 12:51:06.161 TestApp[292:b603] setDetail: Chicken
    2012-03-19 12:51:06.162 TestApp[292:b603] configure view: Chicken
    2012-03-19 12:51:06.175 TestApp[292:b603] View DidLoad
    

    If you want to set the data on the view you’re pushing, you have a couple options.

    1. Call setDetail but in setDetail only set iVar data – don’t manipulate views. Then, in viewDidLoad/WillAppear, read the iVar data and manipulate the views.

    2. Use delegates to have the view you’re pushing call back to the launching view. See What exactly does delegate do in xcode ios project?

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

Sidebar

Related Questions

I want to place UItextField in UITableViewCell but I have problem. Text field don't
I have a problem that I want to set the position of text as
I have a problem as follows: We're using a rich text editor (TinyMCE, but
I have a pretty funny problem which involves loadView , viewDidLoad , viewWillAppear and
I have a set of text inputs fields which I want to be cloned
I have a problem and I want to implement the MVC pattern to my
I have a problem when I want to sending data using byte format in
I have problem with fancybox. I want to write a function that will run
I have problem with return statment >.< I want to store all magazine names
I have problem with HTTP headers, they're encoded in ASCII and I want to

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.