smi*_*lar 1 touch ios uitapgesturerecognizer uicollectionview
我想在屏幕上有手指时禁用UICollectionViewController的自动旋转,就像iPhone照片应用程序那样.
怎么做?
touching,即使在手指移动之后.)touchBegan:withEvent:,在哪里放置该代码?(命中视图可以是UICollectionView的任何子视图.)我会设置一个标志touchesBegan并清除它touchesEnded.然后在您的shouldAutoRotate方法中,您可以检查标志,如果设置了标志,则返回false.
像这样的东西:
// In your UICollectionView subclass:
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
// Do stuff
...
canRotate = NO;
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
// Do stuff
...
canRotate = YES;
}
// In your UICollectionViewController:
-(bool)shouldAutorotate
{
return(canRotate);
}
Run Code Online (Sandbox Code Playgroud)