我在我的应用程序中有一个UIScrollView
,我想基本上在最后一页上添加一个按钮。现在,我在滚动视图下添加故事板中的按钮,并将该按钮的X参数设置为1050,即屏幕宽度为320(iPhone5)的screenWidth * 3 + 90。所以,你可以看到它可以在iPhone5上运行,但不适用于大屏幕6/6Plus。我试图以编程方式重新调整按钮,但它不起作用。添加一个按钮到UIScrollView的最后一页
-(void)viewDidAppear:(BOOL)animated
{
...
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat screenWidth = screenRect.size.width;
CGFloat screenHeight = screenRect.size.height;
[self.tutorialScrollView addSubview:page1];
[self.tutorialScrollView addSubview:page2];
[self.tutorialScrollView addSubview:page3];
[self.tutorialScrollView addSubview:page4];
[self.tutorialScrollView setContentSize:CGSizeMake(screenWidth*4, screenHeight)];
//readjust button
CGRect btFrame = self.tutorialFinish.frame; //self.tutorialFinish is a UIButton
btFrame.origin.x = (90 + screenWidth * 3);
btFrame.origin.y = 492/568 * screenHeight;
self.tutorialFinish.frame = btFrame;
}
nope仍然不起作用 – stud91
会发生什么?位置不正确? – anhtu
是的按钮出现在第三页..以前它是什么 – stud91