UISegmentedControl does not expand the size for the navigation bar / is very squishy

Running through the iPhone SDK book and one example made me create a table and then add a UISegmentedControl to the table for sorting.

I dutifully did this in IB, and it looks great:

Screenshot IB http://img.skitch.com/20100529-83sefni21q4nj51rw1mghh2yj1.jpg

When I run it in a simulator or my phone, it is completely compressed:

Squished http://img.skitch.com/20100529-x3pmr7gkb6xpm766bupi7quy55.jpg

Buttons work just fine, it's just not the size to fit their content. Any ideas what is going wrong?

Here are the attributes that I set:

Attributes http://img.skitch.com/20100529-tp4d69bk8x98c6sjpmcne92etb.jpg

+2
source share
3 answers

OK, so trying to implement @Chris Gummer's answer, I seem to have learned more about how the Size-> View Size property bar works. Default:

The default size is http://img.skitch.com/20100529-gg9dwq5em3557yb1d6d721hpn4.jpg

and it doesn't seem to be a good default. In my book there was no need to correct this, so I did not look at it. Setting the inside horizontal arrow of the window (which I think means "set the width to the available space") did the trick:

Reply http://img.skitch.com/20100529-xt1bqghb4kbm2pbcqf1i1uygab.jpg

+1
source

You can try to explicitly set the width of each of the segmented control components. Click the Size tab at the top of the inspector and set the width for each component.

+1
source

I once experienced the same question. The problem was that the UINavigationController view was not a top-level view in the hierarchy (it was not added directly to the UIWindow), but instead it was added as a subview to another view manager view. This is just an assumption, maybe your problem (or that there are more than one visible view controller).

+1
source

Source: https://habr.com/ru/post/896305/


All Articles