我正在使用 Eureka 表单,并且正在尝试将此滑动图像视图作为标题包含在内。
目前我正在使用自定义视图和这个库
我认为我的问题的根源是手势识别器和“点击”方法引起的。Xcode 在行上抛出一个错误self.presentViewController(ctr,animated: true,completion:nil)
。我知道它不能在 UIView 中显示视图控制器。我只是不确定如何实现在 UIView 子类中呈现视图控制器的相同结果。
这是我的代码:
class profilePicHeader: UIView {
let slideshow = ImageSlideshow()
var slideshowTransitioningDelegate: ZoomAnimatedTransitioningDelegate?
override init(frame: CGRect) {
super.init(frame: frame)
let localSource = [ImageSource(imageString: "GardenExample")!,ImageSource(imageString: "OvenExample")!]
slideshow.backgroundColor = UIColor.whiteColor()
slideshow.pageControlPosition = PageControlPosition.UnderScrollView
slideshow.pageControl.currentPageIndicatorTintColor = UIColor.lightGrayColor();
slideshow.pageControl.pageIndicatorTintColor = UIColor.blackColor();
slideshow.contentScaleMode = UIViewContentMode.ScaleAspectFill
slideshow.setImageInputs(localSource)
let recognizer = UITapGestureRecognizer(target: self, action: #selector(profilePicHeader.click))
slideshow.addGestureRecognizer(recognizer)
slideshow.frame = CGRectMake(0, 0, 320, 200)
slideshow.autoresizingMask = .FlexibleWidth
self.frame = CGRectMake(0, 0, 320, 130)
slideshow.contentMode = .ScaleAspectFit
self.addSubview(slideshow)
}
func click() {
let ctr = FullScreenSlideshowViewController()
ctr.pageSelected = {(page: Int) in
self.slideshow.setScrollViewPage(page, animated: false)
}
ctr.initialImageIndex = slideshow.scrollViewPage
ctr.inputs = slideshow.images
slideshowTransitioningDelegate = ZoomAnimatedTransitioningDelegate(slideshowView: slideshow, slideshowController: ctr)
// Uncomment if you want disable the slide-to-dismiss feature on full screen preview
// self.transitionDelegate?.slideToDismissEnabled = false
ctr.transitioningDelegate = slideshowTransitioningDelegate
self.presentViewController(ctr, animated: true, completion: nil)
}
required init?(coder aDecoder: NSCoder) {
fatalError("init(coder:) has not been implemented")
}
}