2014-08-29 41 views
0
@try { 
     NSArray *viewContrlls=[[self navigationController] viewControllers]; 
     NSUInteger totalelement = [viewContrlls count]; 
     UIViewController *LastElementController = [viewContrlls objectAtIndex:totalelement-2]; 
     [self GotoDifferentViewWithAnimation:LastElementController]; 

    } @catch (NSException * e) { 
     NSLog(@"Exception: %@", e); 
    } 

我想使用上面的代碼得到最後訪問的viewcontroller和回滾那裏的動畫。它顯示最近訪問過的視圖 - 控制正常狀,回推insto的popto顯示錯誤

LastElementController --- <RRLoginViewController: 0x10b324e60> 

但要complietime犯錯,

Pushing the same view controller instance more than once is not supported (<RRLoginViewController: 0x10b324e60>) 

任何幫助.....

+0

是[self.navigationController popViewControllerAnimated:YES]爲你工作? – 2014-08-29 10:10:03

+0

雅,這是工作正常.. – sbrsantanu 2014-08-29 10:10:43

回答

1

你試圖把一個視圖控制器這已在導航堆棧中。因此,您不能通過「再次推送」回到視圖控制器。

[self.navigationController popToViewController:LastElementController animated:YES]; 

會做這項工作,但我想你想保存該視圖控制器的條件。