Changing the text of a button

Discussion in 'iOS Programming' started by newtomacs1234, Jul 29, 2009.

  1. newtomacs1234 macrumors newbie

    Jul 29, 2009
    Hi there,
    I am trying to change the text label of a button on a simple iPhone web app I am developing. Using this command I have been able to change the text:

    buttonToChange.innerHTML = buttonToChange.innerHTML.replace(buttonToChange.textContent,text);

    However after executing this line of code the clickhandler associated with this button will not fire when the button is clicked.

    Is there anyway to simply change the text of a button without affecting its internal properties?

    Many Thanks
  2. duny macrumors newbie


    Sep 21, 2008
    here is a little tid bit of code i use.

    if (whatever) {
            [button setTitle:@"Hide Navigation Bar" forState:UIControlStateNormal];
            [button setTitle:@"Hide Navigation Bar" forState:UIControlStateHighlighted];
        } else {
            [button setTitle:@"Show Navigation Bar" forState:UIControlStateNormal];
            [button setTitle:@"Show Navigation Bar" forState:UIControlStateHighlighted];
  3. dejo Moderator


    Staff Member

    Sep 2, 2004
    The Centennial State
    That's for changing a UIButton's title. I believe the OP has an issue when changing the title of an HTML button, since they are developing a web app. As for why the click no longer works, sorry; I have no idea.

Share This Page