[英]UIButtons don't align correctly upon first load of View Controller
I have a ViewController/View in a TabBar Controller that has 8 UIButtons in a 2x4 grid, sized 75x75, each with a 75x75 background image set on them. 我在TabBar控制器中有一个ViewController / View,它在2x4网格中有8个UIButton,大小为75x75,每个UIButton上都设置了75x75背景图像。 Currently, I've hard coded the XY positions in the Size Inspector in Interface Builder. 目前,我已经在Interface Builder中的Size Inspector中对XY位置进行了硬编码。
When I first load the View, by clicking on the tab bar icon, the bottom two buttons get squished against the row above them - as per this picture: 当我第一次加载View时,通过单击选项卡栏图标,底部的两个按钮相对于它们上方的行被挤压了-如下图所示:
Each button triggers a segue that launches another ViewController with a WebView in it : 每个按钮触发一个segue,segue启动另一个带有WebView的ViewController:
[self performSegueWithIdentifier:@"playVimeo" sender:sender];
In that WebView, there is a back button that triggers another segue to return to the thumbnails page : 在该WebView中,有一个后退按钮,可以触发另一次搜索以返回缩略图页面:
[self performSegueWithIdentifier:@"returnToThumbnails" sender:sender];
When I press the back button and return to the thumbnail view for a second time, the buttons snap to the right place, unlike when they first load, as per this picture: 当我按下后退按钮并再次返回缩略图视图时,按此图片所示,按钮将捕捉到正确的位置,这与它们第一次加载时不同:
Here is a screenshot of my Storyboard: 这是我的情节提要的屏幕截图:
Does anyone have an idea what is going on here ? 有人知道这里发生了什么吗? I am lost... 我搞不清楚了...
Thanks in advance! 提前致谢!
Jesse 杰西
This issue went away when I unselected "Use Autolayout" in the file inspector of the UIViewControllers. 当我在UIViewControllers的文件检查器中取消选择“使用自动布局”时,此问题消失了。
Though as rdelmar pointed out in the comments, it is funny that it was working at all, as I was actually creating a new ViewController with every segue from my back button, and not popping back to the previous existing ViewController. 尽管正如rdelmar在评论中指出的那样,但它确实可以工作很有趣,因为我实际上是使用后退按钮中的每个按钮创建一个新的ViewController,而不是跳回到以前的现有ViewController。 It should have been working the same in both ways, as the View was always loading 'for the first time' ... 它应该在两种方式上都一样工作,因为View总是“第一次”加载...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.