所以我有一个视图控制器,上面有一个图像/按钮。如果单击它,则会在视图控制器上激活模式弹出窗口,并在其上显示相同的图像。图像在UIScrollView上,我为它创建了一个缩放功能。
我能够成功放大图像并多次滚动它,直到它决定停止让我滚动和缩放整个图像,但只有它的左上部分。
仅在我将屏幕倾斜到横向模式并再次激活弹出窗口后才会发生这种情况。看起来弹出窗口中的图像会变大。
约束都是在故事板中完成的。我不确定问题是约束还是代码。
守则:
变量
{
"doorseller" : "e0asda9a0fqqf7-f0asdas66-48c4-bfe5-ssss",
"_class" : "net.bowl.google.microservice.product.domain.Product",
"status" : "MATCHED",
"runningStatus" : "running_CREATED",
"hasValidImage" : true,
"doorID" : "3052007",
"door" : "4ef7a893-4158-4b4b-ba60-26cb9f75b988",
"good" : {
"Ekipman ID" : {
"value" : "",
"detail" : {
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
},
"history" : [
{
"value" : "",
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
}
]
},
"Renk Kodu" : {
"value" : "",
"detail" : {
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
},
"history" : [
{
"value" : "",
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
}
]
},
"Malzeme" : {
"value" : "",
"detail" : {
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
},
"history" : [
{
"value" : "",
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
}
]
},
"doorID" : {
"value" : "3052007",
"detail" : {
"revisedBy" : "admin",
"revisionDate" : ISODate("2017-02-10T07:15:05.405+0000")
},
"history" : [
{
"value" : "3052007",
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
},
{
"value" : "3052007",
"revisedBy" : "admin",
"revisionDate" : ISODate("2017-02-10T07:15:05.405+0000")
}
]
},
"Garanti Notu" : {
"value" : "",
"detail" : {
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
},
"history" : [
{
"value" : "",
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
}
]
},
"Derinlik" : {
"value" : "",
"detail" : {
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
},
"history" : [
{
"value" : "",
"revisedBy" : "door",
"revisionDate" : ISODate("2017-02-07T10:13:34.615+0000")
}
]
}
}}
图像缩放
@IBOutlet var scrollView: UIScrollView!
@IBOutlet var zoomImageView: UIImageView!
@IBOutlet var imageView: UIView!
@IBOutlet var backgroundButton: UIButton!
在方向更改期间居中图像
override func viewDidLoad() {
super.viewDidLoad()
self.scrollView.minimumZoomScale = 1.0
self.scrollView.maximumZoomScale = 6.0
}
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.zoomImageView
}
模态弹出
override func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
if UIDevice.current.orientation.isLandscape{
imageView.center = self.view.center
} else if UIDevice.current.orientation.isPortrait{
imageView.center = self.view.center
}
}
我只提出与问题可能相关的代码。
非常感谢任何帮助。
答案 0 :(得分:0)
我找到了解决方案。问题是animateOut函数末尾的完成块。
而不是:
completion: nil
应该是:
(success:Bool) in
self.imageView.removeFromSuperview()
非常感谢任何花时间浏览我的问题的人。我很高兴能找到这么简单的解决方案。