我如何使用panGestureRecognizer打開sideMenu如果我已經有在frontViewController一些其他的滑動手勢(在我的情況下,它是HomescreenViewController)? 我的frontViewController包含一個5頁的pageViewController.So左側刷卡和右側刷卡已爲pageViewController啓用。SWRevealViewController panGestureRecognizer與pageViewController的iOS(上刷卡側菜單)
我用frontViewController的viewDidLoad中下面的代碼:
_sideButton.target = self.revealViewController; _sideButton.action = @selector(revealToggle:); [self.view addGestureRecognizer:self.revealViewController.panGestureRecognizer]; [self.view addGestureRecognizer:self.revealViewController.tapGestureRecognizer];
這與pageViewController向右掃沿着不會做的工作。 然後我用這個代碼:
self.revealViewController.draggableBorderWidth = self.view.frame.size.width/2;
不過這也是沒有working.I現在用的是最新版本的SWRevealViewController 2.4.0
這是我frontViewController的視圖層次。 HomescreenViewController> pagerView> PageviewController> listingViewController
而且,當側菜單出現,則frontviewController的部分是活動的,並且當我嘗試通過向左滑動到關閉側菜單,識別出它作爲pageviewcontroller滑動。我希望第一個問題的解決方案也能解決這個問題。
UPDATE(回答): 看接受的答案爲題號2 對於第一個問題,如果你遇到像我這樣的問題,只是創建向左寬度20個像素的看法使用下面的代碼並將panGestureRecognizer添加到此視圖(在viewWillAppear
中)。
SWSwipeViewForPanGesture=[[UIView alloc]initWithFrame:CGRectMake(0, 0,20, self.view.frame.size.height)];
_SWSwipeViewForPanGesture.backgroundColor=[UIColor clearColor];
[self.view addSubview:_SWSwipeViewForPanGesture];
[_SWSwipeViewForPanGesture addGestureRecognizer:self.revealViewController.panGestureRecognizer];
此外,我不得不在- (void)revealController:(SWRevealViewController *)revealController didMoveToPosition:(FrontViewPosition)position
方法這是一個委託method.So,你應該確認在viewDidLoad中委託添加以下代碼。
[_SWSwipeViewForPanGesture addGestureRecognizer:self.revealViewController.panGestureRecognizer];
[self.view bringSubviewToFront:_SWSwipeViewForPanGesture];
多數民衆贊成it.It簡單的工作!
感謝您的回答Bhumica.The第二個問題是solved.Is有對pageviewcontroller禁用rightswipe當指數爲零的方式嗎?或者,我們可以添加一個透明的視圖(像你剛纔那樣)對HomescreenViewController的左端並添加revealController.panGestureRecognizer它? – abhi1992
在ipad splitviewcontroller,我看到了一個應用程序中,當我們的指數在0,滑動手勢的作品拿菜單來朝前面。 – abhi1992
@ abhi1992但如果你會把透明視圖上瀏覽量的指數0比你會怎麼刷去到下一個頁面。? – BHUMICA