ERROR: scrollview运行时,手势放大报错:
- 2022-04-22 14:27:53.721664+0800 ScrollDemo2[4556:369749] [framework] CUIThemeStore: No theme registered with id=0
- 2022-04-22 14:27:55.405513+0800 ScrollDemo2[4556:369749] *** Terminating app due to uncaught exception ‘NSGenericException’, reason: ‘The view returned from viewForZoomingInScrollView: must be a subview of the
以下是设置缩放代码源码 :
class ViewController: UIViewController {
@IBOutlet weak var scrollView: UIScrollView!
@IBOutlet weak var checkmarkImg: UIImageView!
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewWillLayoutSubviews() {
scrollView.frame=view.bounds
checkmarkImg.frame=view.bounds
}
}
extension ViewController:UIScrollViewDelegate{
func viewForZooming(in scrollView: UIScrollView) -> UIView? {
return self.checkmarkImg
}
}
解决方案:
返回scroll view里面的UIImageView的对象:self.checkmarkImg,而不是myScrollView
把return self.scrollView 改成: return self.checkmarkImg
效果:缩放前后效果
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/101620.html