我环顾四周,我不能为我的生活找到一种用滑动手势替换backbarbuttonitem
的方法。我想向左滑动,让应用程序恢复到以前的视图控制器。只是为了澄清我正在使用UINavigationController
来管理我的所有View控制器。有任何想法吗?或者这不可能吗?谢谢!
答案 0 :(得分:5)
我把它解决了,现在我觉得这个问题很愚蠢!这是我使用的代码:
我在ViewDidLoad
函数中创建了一个滑动手势:
- (void)viewDidLoad
{
[super viewDidLoad];
// -- EDIT Added the allocation of a UIGestureRecognizer -- //
UISwipeGestureRecognizer *swipeRight = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(gotoPreviousView:)];
swipeRight.numberOfTouchesRequired = 1;
swipeRight.direction = UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swipeRight];
}
然后我简单地创建了这个......
- (void)gotoPreviousView:(id)sender {
[self.navigationController popViewControllerAnimated:YES];
}
轻松!看得太远了,答案就是盯着我的脸。希望如果你不知道怎么做,你会看到这一点而不是我做的那个新手错误...