我花了整个周末试图弄清楚为什么我的手势不起作用。当我作为模型视图呈现时,手势正在工作,但是当我添加为子视图时,手势不起作用。是否有任何理由为什么它仅在添加为子视图时才起作用。
此代码有效:
myVC = [[FullViewController alloc] initWithNibName:@"FullViewController" bundle:nil];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController: myVC];
navigationController.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentModalViewController:navigationController animated:YES];
navigationController.view.superview.bounds = CGRectMake(0,0,1024,724);
此代码不起作用:
myVC = [[FullViewController alloc] initWithNibName:@"FullViewController" bundle:nil];
myVC.view.frame = CGRectMake(0, 0, 1024, 724);
myNavCtrl = [[UINavigationController alloc] initWithRootViewController:myVC];
[self.view addSubview: myNavCtrl.view];
myNavCtrl.view.frame = CGRectMake(0, -20, 1024, 675);
手势识别代码:
swipeLeft = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipeLeft:)];
[swipeLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[self.view addGestureRecognizer:swipeLeft];
任何帮助都会被学徒。