Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios UITapGestureRecognitor不';我不在风景区工作_Ios_Swift_Orientation_Landscape_Icarousel - Fatal编程技术网

Ios UITapGestureRecognitor不';我不在风景区工作

Ios UITapGestureRecognitor不';我不在风景区工作,ios,swift,orientation,landscape,icarousel,Ios,Swift,Orientation,Landscape,Icarousel,我正在尝试将tap识别器添加到我的iCarousel项目中。为了实现这一点,我写了以下内容: func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView { let rView = UIView(frame: someOtherView.frame) let imageView = UIImageView(frame: someO

我正在尝试将tap识别器添加到我的
iCarousel
项目中。为了实现这一点,我写了以下内容:

func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView {
    let rView = UIView(frame: someOtherView.frame)
    let imageView = UIImageView(frame: someOtherView.frame)
    imageView.frame.size.height -= 30
    imageView.frame.size.width -= 50
    imageView.image = (images[index])
    imageView.contentMode = .ScaleAspectFit
    imageView.backgroundColor = UIColor.whiteColor()
    imageView.userInteractionEnabled = true
    rView.addSubview(imageView)
    if let gestures = rView.gestureRecognizers {
        for gesture in gestures {
            rView.removeGestureRecognizer(gesture)
        }
    }
    let tap = UITapGestureRecognizer(target: self, action: #selector(ViewController.moveCarousel(_:)))
    rView.addGestureRecognizer(tap)
    print(rView.gestureRecognizers)
    setImageToCenter(imageView)
    return rView
}
这在纵向模式下工作良好。然而,当我旋转到横向时,它不起作用。当我点击视图时,不会发生任何事情。当屏幕旋转时,我称之为:

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
    slider.setWidth()
    trademarkCarousel.reloadData()
}

当我的设备处于横向时,如何运行
TapGestureRecognitor
?谢谢。

您找到解决方案了吗?没有,很遗憾,我没有找到。你有什么想法吗?