当我将旋钮上的按钮移动到横向时,移动正常,但是当我点击时,它们都会消失。有谁知道为什么?
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];
答案 0 :(得分:2)
这是因为您在故事板中使用了自动布局。您无法更改使用自动布局约束定位的视图的frame
;是约束定位它。使用约束(最好是故事板中的约束)来执行您在代码中执行的操作。