简体   繁体   English

移动iOS后单击时按钮消失

[英]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; 您无法更改使用自动布局约束定位的视图的frame it is the constraints that position it. 是它的局限性 Use constraints (preferably the constraints in the storyboard) to do what you are doing here in code. 使用约束(最好是情节提要中的约束)来执行代码中的操作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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