ios - UIImageView 不会拉伸(stretch)到整个屏幕

标签 ios objective-c iphone uiimageview viewcontroller

我在 Storyboard (Xcode 6) 中创建了一个应用程序和导航以及我在 ViewControllers 中的 UIImageView 的原型(prototype),它不会拉伸(stretch)到全屏。例如,我有一个 640×1136 图像的 UIImageView。如果我在 iPhone 5 上运行它,它会全屏显示。但如果我在 iPhone 6 或 6 Plus 上运行它,它位于左上角。我阅读了很多主题和文章,但没有任何帮助。

enter image description here

enter image description here

最佳答案

确保您的 UIImage 位于 UIImageView 中,然后添加约束或更改内容模式,如下所示:

myImageView.contentMode = UIViewContentModeScaleAspectFit;

或者在 View 下的属性检查器中的 Storyboard中更改它。

Here is a list of all the values you can set for this property.

编辑:仔细阅读您的问题,我认为您肯定需要为您的 View 添加约束。有很多关于如何执行此操作的教程:here is apples.

您可以通过单击图钉菜单添加约束,然后单击四个红色括号并单击“添加约束”。

enter image description here

关于ios - UIImageView 不会拉伸(stretch)到整个屏幕,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29397072/

相关文章:

iphone - NSDateFormatter 关闭一小时

ios - 在试飞中发布时推送通知不会到来

ios - 如何将字典转换为数组

ios - 在 iOS7 中更改安全 UITextField 奇怪行为中的 UIFont

objective-c - 按下按钮时应用程序崩溃

ios - 使用 RestKit 的嵌套对象映射

iphone - 调整UIImagePickerController视频采集界面大小

ios - Swift3/Firebase 数据库 : How can I get sub key of value?

ios - 在使用 cordova 的 iOS 应用程序中找不到 PushPlugin

iphone - 如何将 NSDate 转换为 NSString?