我有一个TabBarController有两个选项卡.在每个标签中我都有UICollectionView,UITapGestureRecognizer每次点击时都会触发collectionView.应用程序启动后,一切正常.但如果我转向横向,TapGestureRecognizer只能在collectionView旧框架中发射.它绝对忽略了屏幕的右侧.
但是,如果我切换到另一个选项卡然后返回,它也适用于横向方向.我只是不明白我做错了什么.
这就是我改变方向模式的方法collectionView:
-(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[super willRotateToInterfaceOrientation:toInterfaceOrientation duration:duration];
[self.cardCollectionView.collectionViewLayout invalidateLayout];
}
Run Code Online (Sandbox Code Playgroud)