Frage

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

  • When I press "Edit", its name changes to "…", which is not what it's supposed to do.
  • However, it does behave properly if I change the name to "12345" in Interface Builder.
  • If I change the name to "Edit2" (note, also five letters), it changes to "D…e".
  • If I name it to something short, like "NS", it also produces three dots.

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

War es hilfreich?

Lösung

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).

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top