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

  • Home
  • SEARCH
  • 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 6867143
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:16:22+00:00 2026-05-27T03:16:22+00:00

How can we set the button title for a button,i know this answer its

  • 0

How can we set the button title for a button,i know this answer its simple,we need to set the title of the button for title ,but my need is somewhat diffrent ,i had a username which dynamically changes according to login.i set this in a button click and display it in a label within that button .my code for this is

- (void)getFacebookProfileFinished:(ASIHTTPRequest *)request
{

    // Use when fetching text data
    NSString *responseString = [request responseString];
    NSLog(@"Got Facebook Profile: %@", responseString);

    NSString *likesString;
    NSMutableDictionary *responseJSON = [responseString JSONValue];   

    NSString *username;
    NSString *firstName = [responseJSON objectForKey:@"first_name"];
    NSString *lastName = [responseJSON objectForKey:@"last_name"];
    if (firstName && lastName) {
        username = [NSString stringWithFormat:@"%@ %@", firstName, lastName];
    } else {
        username = @"mysterious user";
    }
     [_loginButton setTitle:username forState:UIControlStateNormal];
    _lblfaceusername.text = username;


    [self refresh];    
}

i need to display the user name in another button click and have to assing the title of that button to user name the code for this is

- (void)refresh {
    if (_loginState == LoginStateStartup || _loginState == LoginStateLoggedOut) {
        _loginStatusLabel.text = @"Not connected to Facebook";
        [_loginButton setTitle:@"Login" forState:UIControlStateNormal];
        _loginButton.hidden = NO;
    } else if (_loginState == LoginStateLoggingIn) {
        _loginStatusLabel.text = @"Connecting to Facebook...";
        _loginButton.hidden = YES;
    } else if (_loginState == LoginStateLoggedIn) {
        _loginStatusLabel.text = @"Connected to Facebook";
        [_loginButton setTitle:@"" forState:UIControlStateNormal];
        _loginButton.hidden = NO;
    }   
}

i need to set the username in the [_loginButton setTitle:@"" forState:UIControlStateNormal];i want [_loginButton setTitle:username forState:UIControlStateNormal];

  • 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-27T03:16:22+00:00Added an answer on May 27, 2026 at 3:16 am

    Anyhow you have set the button title in the method

    - (void)getFacebookProfileFinished:(ASIHTTPRequest *)request
    

    after facebook request done. Then, why you need to set that again in refresh method? Just comment out the line in LoginStateLoggedIn condition in refresh method.

    //[_loginButton setTitle:@"" forState:UIControlStateNormal];
    

    Edit

    - (void)refresh {
        if (_loginState == LoginStateStartup || _loginState == LoginStateLoggedOut) {
            _loginStatusLabel.text = @"Not connected to Facebook";
            [_loginButton setTitle:@"Login" forState:UIControlStateNormal];
            _loginButton.hidden = NO;
        } else if (_loginState == LoginStateLoggingIn) {
            _loginStatusLabel.text = @"Connecting to Facebook...";
            _loginButton.hidden = YES;
        } else if (_loginState == LoginStateLoggedIn) {
            _loginStatusLabel.text = @"Connected to Facebook";
            NSString *username = [_loginButton titleForState:UIControlStateNormal];
            [_loginButton setTitle:username forState:UIControlStateNormal];
            _loginButton.hidden = NO;
        }   
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any sort of XY-Layout to Java? So I can set a Button
Normally with Java Swing you can set the background color of a button with:
How to set a bitmap as a button so that i can apply button
I can set data in JTable constructor, and then user can change this data
You can set the Vim color scheme by issuing :colorscheme SCHEME_NAME but, oddly enough,
How can I can set a global variable for the username of the logged-in
I think the title for this question is probably wrong, but I'm not sure
A .NET Windows form can have a help button on the title bar when
How can I in Interface Builder set NSButton of type toggle with Title and
How can I set the title of UIToolBar such that it looks the same

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.