user3124010
user3124010

Reputation:

When using setTitle:forState: (UIButton) it produces strange results

I am doing en exercise from my programming book. I have set up a small custom view in Interface Builder.

Custom view

I have set "Edit"-button's event to toggleEditMode: in File's owner.

The view controller that is handling the view (the view is a table header view) has the following implementation of toggleEditMode:

- (IBAction)toggleEditingMode:(id)sender
{
    if (self.isEditing)
    {
        [sender setTitle:@"Edit"
                forState:UIControlStateNormal];

        [self setEditing:NO
                animated:YES];
    }
    else
    {
        [sender setTitle:@"Done"
                forState:UIControlStateNormal];

        [self setEditing:YES
                animated:YES];
    }
}

In Interface Builder I have also set File's owner custom class to my view controller. The UIView background is also set to the correct property in the view controller.

The problem

Does anyone know what's going on? I followed my book, and in the book it works properly.

Upvotes: 0

Views: 97

Answers (1)

user3124010
user3124010

Reputation:

Note: Full credit should go to Matthias Bauch, who answered this in the comments.

The text strings that are too long for a button will be truncated. To solve this you make the frame of the button larger, by draging in the corners of it (in Interface Builder).

Upvotes: 1

Related Questions