Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Button text not showing and xcode crashing

I am just starting out learning IOS development. I've spent days trying to troubleshoot this problem and I'm getting nowhere. Hopefully someone can help.

I was working on a calculator app for the iPhone (just for practice). I created a grid of buttons, but as I started to create the final row xCode kept crashing after I created or moved each button. I eventually got the layout created, but when I run the app the button text does not show for any button on the bottom row (in IOS simulator or on my iPhone):

             +----+ +----+ +----+ +----+ +----+
             | 7  | | 8  | | 9  | | +  | | -  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 4  | | 5  | | 6  | | /  | | *  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 1  | | 2  | | 3  | |    | | AC |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ |    | +----+
                                  | =  |
             +----+ +----+ +----+ |    | +----+
             |    | |    | |    | |    | |    |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

If I move the buttons from the bottom row to the top one by one the text displays on them, but still not on the bottom row:

                    +----+ +----+        +----+
                    | .  | | +- |        | C  |
                    |    | |    |        |    |
                    +----+ +----+        +----+

             +----+ +----+ +----+ +----+ +----+
             | 7  | | 8  | | 9  | | +  | | -  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 4  | | 5  | | 6  | | /  | | *  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 1  | | 2  | | 3  | |    | | AC |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ |    | +----+
                                  | =  |
             +----+               |    |
             |    |               |    |
             |    |               |    |
             +----+               +----+

Then, as I move the final button to the top, the new bottom row stops displaying text:

             +----+ +----+ +----+        +----+
             | 0  | | .  | | +- |        | C  |
             |    | |    | |    |        |    |
             +----+ +----+ +----+        +----+

             +----+ +----+ +----+ +----+ +----+
             | 7  | | 8  | | 9  | | +  | | -  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 4  | | 5  | | 6  | | /  | | *  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 1  | | 2  | | 3  | |    | | AC |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ |    | +----+
                                  |    |
                                  |    |
                                  |    |
                                  |    |
                                  +----+

Then I move the equals button up, and the new bottom row fails to display text:

                                  |    |
                                  |    |
             +----+ +----+ +----+ | =  | +----+
             | 0  | | .  | | +- | |    | | C  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 7  | | 8  | | 9  | | +  | | -  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+ +----+ +----+
             | 4  | | 5  | | 6  | | /  | | *  |
             |    | |    | |    | |    | |    |
             +----+ +----+ +----+ +----+ +----+

             +----+ +----+ +----+        +----+
             |    | |    | |    |        |    |
             |    | |    | |    |        |    |
             +----+ +----+ +----+        +----+

This is really frustrating! I have started again in a new app get the same thing, always the lowest aligned row that doesn't show. If I switch to 3.5" view the problem is still there. I've tried spacing the buttons out further, played around changing all the text parameters, changed the view to disable autoresize subviews and changed mode from scale to fit but this is still happening. I can't find any other posts describing this issue, which seems odd as it's easily re-creatable. Please help.

like image 536
Karl Billington Avatar asked Mar 25 '26 07:03

Karl Billington


2 Answers

I recommend to use the new autolayout-option of iOS 6 only in very special cases. I have tested this option very intensively and find out a lot of bugs, e.g.:

  • in the console appear messages indicating apple bugs
  • it slows down your UI dramtically
  • while layouting constraints suddenly disappear
  • the app sometimes crashes with undocumented error messages

Using autolayout is currently very frustrating. Instead of using autolayout I use

- (void)viewDidLayoutSubviews {}

to adjust my UI programmatically, which is much easier and faster (at developing and at runtime).

like image 59
Dominic Sander Avatar answered Mar 26 '26 22:03

Dominic Sander


You need to un click the "Use Autolayout" toggle under "Interface Builder Document. I had this same problem, and after disabling it the text displays correctly in the buttons.

Show utilities / File inspector / Interface builder / Use Autolayout

As far as I know, this is a new "feature" of iOS 6.1

like image 22
user2101258 Avatar answered Mar 26 '26 21:03

user2101258



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!