분명히 솔루션 개요는 여기에서 찾을 수 있습니다 : 내 솔루션에서 UINavigationController and UINavigationBarDelegate.ShouldPopItem() with MonoTouch
, 난 그냥 모두 내보기 컨트롤러는 다음과 같습니다 CustomUINavigationController를 확장 :
#import "CustomUINavigationController.h"
#import "IOSVersion.h"
@interface CustomUINavigationController()
@end
@implementation CustomUINavigationController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.delegate=self;
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
//
// The following two methods are the key to overriding the buggy behavior in IOS 8
// The first method is from here:
// https://stackoverflow.com/questions/6413595/uinavigationcontroller-and-uinavigationbardelegate-shouldpopitem-with-monotouc
//
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item {
NSLog(@"Inside shouldPopItem");
if (regularPop) {
NSLog(@"regularPop is TRUE");
} else {
NSLog(@"regularPop is FALSE");
}
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
if (regularPop) {
regularPop = FALSE;
return YES;
}
regularPop = TRUE;
[self popViewControllerAnimated:YES];
return NO;
} else {
return [super navigationBar:navigationBar shouldPopItem:item];
}
}
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
NSLog(@"Inside popViewControllerAnimated");
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
NSMutableArray *viewControllers = [NSMutableArray arrayWithArray:self.viewControllers];
int cnt=(int)[viewControllers count];
NSLog(@"Inside popViewControllerAnimated, cnt is %d",cnt);
UIViewController *vc=[viewControllers objectAtIndex:cnt-2];
if (regularPop) self.desiredVC=vc;
[self popToViewController:vc animated:animated];
return vc;
} else {
return [super popViewControllerAnimated:animated];
}
}
- (UIViewController *)manualpopViewControllerAnimated:(BOOL)animated {
NSLog(@"Inside manualpopViewControllerAnimated");
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(@"8.0")) {
regularPop=TRUE;
return [self popViewControllerAnimated:animated];
} else {
return [super popViewControllerAnimated:animated];
}
}
- (void)navigationController:(UINavigationController *)navigationController
didShowViewController:(UIViewController *)viewController
animated:(BOOL)animated {
NSLog(@"Inside didShowViewController");
if (viewController==self.desiredVC) {
NSLog(@"Inside didShowViewController, found desiredVC");
regularPop = FALSE;
}
}
/*
#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
*/
@end
포함 할 수있다 탐색 스택에 밀어 넣기 위해 사용하는 메커니즘 스토리 보드를 사용합니까? 섹스를 사용하고 있습니까? pushViewController를 사용하고 있습니까? 또한 로그에 손상된 탐색 스택에 대한 언급이 있습니까? – atreat
난 그냥 옛 표준 pushViewController를 사용하고 있습니다. 나는 스토리 보드 나 섹스를 사용하지 않는다. 이것은 IOS와 XCode의 이전 버전에서 잘 작동하지만 IOS8에서 XCode 6을 사용하여 깨진 것 같은 정말 기본적인 IOS 코딩입니다. – Marc
안녕하시오? 나는 똑같은 문제가있다 –