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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:09:50+00:00 2026-05-25T20:09:50+00:00

I hope this is a simple question, I have a UIBarButtonItem which I initialized

  • 0

I hope this is a simple question, I have a UIBarButtonItem which I initialized using a UILabel as a custom view, the button is living inside toolbar.
What I want to do is being able to change the text from the label that is inside the UIBarButtonItem, here is my code:

    NSDate *lastUpdateDate = [AWSyncEntity getLastUpdatedDateByEntityName:@"Patient" inManagedObjectContext:self.managedObjectContext]; 

    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];//liberar
    [dateFormat setDateFormat:@"MM/dd/yyyy hh:mm a"];

    UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 180, 44.01)]; //liberar
    myLabel.font = [UIFont boldSystemFontOfSize:10];
    myLabel.textColor = [UIColor whiteColor];
    myLabel.backgroundColor = [UIColor clearColor];
    myLabel.text = [NSString stringWithFormat:@"Actualizado: %@", [dateFormat stringFromDate:lastUpdateDate]];

    UIBarButtonItem *btn2 = [[UIBarButtonItem alloc] initWithCustomView:myLabel]; //liberar    
    UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; //liberar        
    self.toolbarItems = [NSArray arrayWithObjects:flexibleSpace,btn2, flexibleSpace, nil];
    [self.navigationController setToolbarHidden:NO animated:YES];

    UIBarButtonItem *mybtn = (UIBarButtonItem *)[self.toolbarItems objectAtIndex:2];    
    //I was thinking this would be possible...
    //UILabel *mylbl = (UILabel *) [mybtn view];

    [flexibleSpace release];
    [btn2 release];
    [myLabel release];
    [dateFormat release];

I have no idea how to gain reference to the inner view of the button again, any clues?
I was thinking on doing something like this: (but it is not working).

    //I was thinking this would be possible...
    //UILabel *mylbl = (UILabel *) [mybtn view];
  • 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-25T20:09:51+00:00Added an answer on May 25, 2026 at 8:09 pm

    The label is the customView of bar button,

    UILabel *mylbl = (UILabel *)[mybtn customView];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Very simple question I hope. I have the usual <select> box like this <select
Simple question I hope. If I have a set of data like this: Classification
i hope this question is not too simple, but i have no idea :(
I hope this is a simple enough question for any SQL people out there...
I hope this is not a duplicate of a question, but I have three
I have a simple question for you (i hope) :) I have pretty much
I hope this question isn't too simple, I tried to go through the postgresql
This is my first question here and I hope it is simple enough to
I have a simple question about Java's XML API and I hope there's a
I have a simple question; hope you can help me. I have coded a

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.