简体   繁体   English

第一次加载View Controller时,UIButton不能正确对齐

[英]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.

相关问题 以编程方式设置视图。 在UIView子类中添加了UIButton。 UIButton直观地显示它们被单击,但不响应选择器 - Set view programmatically. UIButtons added in UIView subclass. UIButtons visually show they are clicked but don't respond to selectors iPhone Dev:Tab视图控制器。 第一个视图上的按钮不显示“文件所有者”中的操作 - iPhone Dev: Tab View controller. Buttons on first view don't show actions in File's Owner 如何显示视图控制器上存在的UIButton - How to show UIButtons present on the view controller 在视图控制器宽度上水平均匀分布UIButton的最简单方法是什么? - Simplest way to evenly distribute UIButtons horizontally across width of view controller? 在自动旋转设定帧后,UIButtons不响应触摸 - UIButtons don't respond to touch after set frame on autorotate View Controller无法正确显示 - View Controller not Displaying Correctly 不要自动旋转视图控制器,而是显示UIAlertView旋转 - Don't autorotate view controller, but show UIAlertView rotated 从AppDelegate导航到视图控制器不会禁用以前的视图控制器的音频播放 - Navigation from AppDelegate to a view controller don't disable the audio playing of previous view controller 通过UIButtons的Tabbar控制器? - Tabbar controller through UIButtons? 如何在圆圈内对齐 UIButton? - How to align UIButtons within a circle?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM