移动iOS后单击时按钮消失

时间:2016-03-16 22:43:36

标签: ios objective-c

当我将旋钮上的按钮移动到横向时,移动正常,但是当我点击时,它们都会消失。有谁知道为什么?

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];

1 个答案:

答案 0 :(得分:2)

这是因为您在故事板中使用了自动布局。您无法更改使用自动布局约束定位的视图的frame;是约束定位它。使用约束(最好是故事板中的约束)来执行您在代码中执行的操作。