iOS手勢之UISwipeGestureRecognizer的正確用法
swipe.direction的值都是3.
下面是我以前的程式碼:
UISwipeGestureRecognizer *swiperight=[[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(swichController:)];
//預設是UISwipeGestureRecognizerDirectionRight
swiperight.direction=UISwipeGestureRecognizerDirectionRight|
UISwipeGestureRecognizerDirectionLeft
[self.collectionaddGestureRecognizer:swiperight];
他是錯誤的。
正確的用法是,要建立倆個輕拍手勢,分別設定他的方向才可以。
//新增輕掃手勢
UISwipeGestureRecognizer *swipe=[[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(swichController:)];
//預設是UISwipeGestureRecognizerDirectionRight
swipe.direction=
[self.collectionaddGestureRecognizer:swipe];
UISwipeGestureRecognizer *swiperight=[[UISwipeGestureRecognizeralloc]initWithTarget:selfaction:@selector(swichController:)];
//預設是UISwipeGestureRecognizerDirectionRight
swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[self.collectionaddGestureRecognizer:swiperight];