2

我环顾四周,终生无法找到backbarbuttonitem用滑动手势替换的方法。我想向左滑动并让应用恢复到以前的视图控制器。只是为了澄清我正在使用 aUINavigationController来管理我的所有视图控制器。有任何想法吗?或者这是不可能的?谢谢!

4

1 回答 1

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];
}

简单的!看得太远了,答案正盯着我的脸。希望如果你不知道怎么做,你会看到这一点,而不是犯我做过的同样的菜鸟错误……

于 2012-08-22T11:02:11.770 回答