简体   繁体   中英

Buttons Disappear when I click after moving iOS

When I move my buttons upon rotation to landscape, the move properly but when I click, they all disappear. Does anyone know why?

UIButton *recordingButton = (UIButton *)[self.view viewWithTag:1];
CGRect frame1 = [recordingButton frame];
frame1.origin.x += 255;
frame1.origin.y -= 250;// change the location
[recordingButton setFrame:frame1];

UIButton *streamingButton = (UIButton *)[self.view viewWithTag:2];
CGRect frame2 = [streamingButton frame];
frame2.origin.x += 255;
frame2.origin.y -= 250;// change the location
[streamingButton setFrame:frame2];

UIButton *uploadButton = (UIButton *)[self.view viewWithTag:3];
CGRect frame3 = [uploadButton frame];
frame3.origin.x += 255;
frame3.origin.y -= 250;// change the location
[uploadButton setFrame:frame3];

It's because you're using auto layout in your storyboard. You can't go changing the frame of a view positioned using auto layout constraints; it is the constraints that position it. Use constraints (preferably the constraints in the storyboard) to do what you are doing here in code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM