0

I'm developing an Enterprise app for tracking mileage and maintenance for company vehicles. I've added graphic buttons to snazz it up a bit. The buttons look the way they're supposed to look on the XIB in IB, and on the iPhone all other UIViews look correct, but on one particular UIView the graphic images are stretched way out of proportion vertically.

The first image below shows how it's supposed to look, with the three graphics buttons at the bottom. The second image shows how it's showing on the phone. The Help button on this screen cap shows normally, but it can't be counted on to stay that way.

It also is not consistent. Calling this view at any time may show the image stretched or it may not show an image at all. It rarely shows the image normally, like the Help button looks below.

The development phone is a 4S running 6.1.3. The views are set for the Retina 3.5 screen. XCode is the latest (whatever it is).

The way it's supposed to look

The way it looks on the phone

Again, it's only on this one view that the problem shows up. There is another UIView on the same view controller that is hidden when this UIView is shown. The button graphics on the other view look fine. All of the other views and view controllers use the same graphics on the UIButton, without any problem.

4

3 回答 3

1

无需关闭自动布局。自动布局可能非常有用,但它似乎喜欢在重新定位 UIButtons 后将 约束“对齐基线到:”随机分配给它们。

只需在 Storyboard 中选择有问题的 UIButton/UIImageView,找到约束"Align Baseline to:",点击齿轮图标并选择"Promote to User Constraint",然后再次点击并选择"Delete"。这应该可以解决您的问题。

于 2013-08-22T19:35:01.447 回答
1

在 Interface Builder (Xcode) 中,您使用 4.5 英寸的屏幕高度创建了视图。

但是您看到问题的设备是 5 英寸屏幕。所以视图被调整大小以适应。

当它这样做时,Interface Builder 对这些子视图施加的自动布局约束会接管以确定它们的作用。这些限制正在导致高度发生变化。

于 2013-05-14T21:30:06.643 回答
0

作为对这里的评论的回应,我将回答我自己的问题:我为这个视图控制器关闭了自动布局,这解决了所有问题。这是自 XCode 开始为 iPhone 5 开发以来我编写的第一个应用程序,所以我不知道 Autolayout 功能。我需要了解它是如何工作的,以及它为什么会这样做。

感谢你的帮助!

于 2013-05-14T21:47:38.700 回答