2012-06-15 38 views
3

我知道如何處理Storyboard中的push segues以及使用導航控制器創建的後退按鈕。我有一個主桌面視圖通過Storyboard中的push segue連接到一個子桌面視圖。適用於在表格之間切換。如何解除由storyboard push segue調用的代碼中的TableViewController?

我想添加的能力也手勢滑動左兒童tableview返回到主tableview。

首先在Storyboard中使用滑動手勢識別器嘗試了這一點,但這導致主tableview成爲子tableview的新子。

然後我在代碼中嘗試:

[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]; 

...但這似乎只能用一個模式賽格瑞工作

我:

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    UISwipeGestureRecognizer *recognizer = [[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector(handleSwipe:)]; 
    [recognizer setDirection:(UISwipeGestureRecognizerDirectionLeft)]; 
    [self.tableView addGestureRecognizer:recognizer]; 
} 

- (void)handleSwipe:(UISwipeGestureRecognizer *)gestureRecognizer 
{ 
    // need code here to dismiss the child tableview 
} 

回答

4

今天終於想通了,並它完美的作品:

- (void)handleSwipe:(UISwipeGestureRecognizer *)gestureRecognizer 
{ 
    [self.navigationController popViewControllerAnimated:YES]; 
} 

找到的答案在:

iOS開發庫> UINavigationController類參考> popToViewController

相關問題