我是 iOS 应用程序开发的新手,我开始从这个很棒的教程中学习:
开始开发 iOS 应用程序 (Swift)
一切看起来都很棒,但是当尝试从模拟器上的“相机胶卷”加载图像时,我得到的图像显示过大并填满了所有 iPhone 模拟器屏幕,而不是只显示在 UIImageView 框中,如教程图像所示。
有趣的事实是,下载课程末尾提供的正确项目(见页面底部)我也遇到了同样的问题。
谷歌搜索我得到一些想法来插入:
// The info dictionary may contain multiple representations of the image. You want to use the original
guard let selectedImage = info[UIImagePickerControllerOriginalImage] as? UIImage else {
fatalError("Expected a dictionary containing an image, but was provided the following: \(info)")
}
// Set photoImageView to display the selected image
photoImageView.image = selectedImage
photoImageView.contentMode = UIViewContentMode.scaleAspectFit
// Dismiss the picker
dismiss(animated: true, completion: nil)
从相机胶卷加载图像后,但没有结果...
我使用 Xcode 9.2 和部署目标 11.2 和 iPhone 8 plus 作为模拟器的目标。
任何帮助都将不胜感激。