Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Misplaced UISegmentedControl (potential bug)

I'm pretty new to using Apple NSAutolayout. In the easiest example I could imagine I created tabbed iPhone App with default template. Then in first view i added UISegmentedControl and add 2 constraints to him: "Align Center X to: SuperView" and "Bottom Space to: Bottom Layout Guide". Then when I run app the UISegmentedControl position is correct but when I switch to the second view and go back, the UISegmentedControl goes down and becomes hidden by UITabBar. When I rotate device the segmented control position goes back to the right place.

Is there a solution to avoid this?

EDIT: Few snapshots to show problem.

Before http://img824.imageshack.us/img824/6830/o2v2.png After http://img5.imageshack.us/img5/2205/ksb6.png

EDIT 2: I found temporary solution.

All you need to store data using property for example:

@property (nonatomic, assign) CGRect fix_didLoadSegmentedFrame;

Then in viewDidLoad and function where you handle value changing UISegmentedControl you should add line:

self.fix_didLoadSegmentedFrame = self.mapTypeSegmentedControl.frame;

You should also set "Apply retina 3.5-inch from factor" storyboard property.

like image 704
Szu Avatar asked Nov 12 '22 18:11

Szu


1 Answers

Try using this in viewDidLoad:

self.tabBarController.tabBar.translucent = NO;

like image 89
Gabriel Hernández Avatar answered Nov 15 '22 06:11

Gabriel Hernández