표준 UINavigation 컨트롤러가 있으며 정상적으로 푸시 및 팝 모드로 내 화면을 밀어냅니다. 그러나, 나는 하나의 화면을 두 개의보기 컨트롤러 사이에서 전환하는 버튼을 눌러 그래서 화면이 넘는 다른 viewcontroller 및 비자를 공개합니다. 당신은 그들 사이에서 자유롭게 전환 할 수 있습니다. UINavigationController를 수정하면 탐색 스택이 손상됩니다.
-(IBAction)switchToSlowProductEntry:(id)sender
{
NSLog(@"Switching to slow product entry");
// Replace the top view with the findProductView
FindProductView *findProdView = [ProductViewInstances shared].findProductView;
NSMutableArray *views = [self.navigationController.viewControllers mutableCopy];
[views removeLastObject];
[views addObject:findProdView];
// if sender is nil then assume we started from the viewDidLoad so no animation
if(sender)
{
[UIView transitionWithView:self.navigationController.view duration:0.3 options:UIViewAnimationOptionTransitionFlipFromRight animations:^
{
[self.navigationController setViewControllers:views animated:NO];
}
completion:^(BOOL finished) {}];
}
else
[self.navigationController setViewControllers:views animated:NO];
NSLog(@"Views: %@", views);
[views release];
[ProductViewInstances shared].lastScreen = SlowProductEntryView;
}
-(IBAction)switchToQuickProductEntry:(id)sender
{
NSLog(@"Switching to fast product entry");
// Replace the top view with the findProductView
QuickOrderEntryView *quickProductView = [ProductViewInstances shared].quickProductView;
NSMutableArray *views = [self.navigationController.viewControllers mutableCopy];
[views removeLastObject];
[views addObject:quickProductView];
if(sender)
{
[UIView transitionWithView:self.navigationController.view duration:0.3 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^
{
[self.navigationController setViewControllers:views animated:NO];
}
completion:^(BOOL finished) {}];
}
else
[self.navigationController setViewControllers:views animated:NO];
NSLog(@"Views: %@", views);
[views release];
[ProductViewInstances shared].lastScreen = QuickProductEntryView;
}
내가 다른 화면 코드 유사한 부분이 있습니다
지금, 나는 뒤로 버튼 그래서 다음과 같이 이것을 달성하기 위해 상위 뷰 컨트롤러를 교체 정상 작동합니다. 나는 화면에서 스테이지를 유지하면서 클래스를 언로드하지 않으려 고하므로 두 개의 View Controller를 유지 관리하기 위해 ProductViewInstances 클래스를 사용하고 있습니다.
이 화면에서 앞으로 나아갈 때, 나는 새로운 화면에 평소대로 밀어 넣습니다. 그것은 작동하고 나는 내가 추가 한 제품을 검토 한 후에 돌아 간다. 다시 누르면 위의 화면으로 돌아가고 모든 것이 정상적으로 보입니다. 그러나, 내가 다시 사용자 정의 뒤로 버튼을 누르면 (내가 누르면 다시 처리해야합니다) 나는 문제가 생겼다.
popViewController는 아무 작업도 수행하지 않습니다. 다음은 사용자 정의 뒤로 버튼을 관리하는 기본 클래스의 코드입니다.
-(void) viewDidLoad
{
self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil)
style:UIBarButtonItemStyleBordered
target:self
action:@selector(myCustomBack)] autorelease];
if(![ProductViewInstances shared].findProductView)
{
[ProductViewInstances shared].findProductView = [[FindProductView alloc] init];
[ProductViewInstances shared].findProductView.customer = self.customer;
}
if(![ProductViewInstances shared].quickProductView)
{
[ProductViewInstances shared].quickProductView = [[QuickOrderEntryView alloc] init];
[ProductViewInstances shared].quickProductView.customer = self.customer;
}
}
-(void) goBack
{
if([[ProductViewInstances shared].quickProductView checkIfItemsPending])
{
// Pop up dialog
UIAlertView * alert = [[UIAlertView alloc] initWithTitle:NSLocalizedString(@"Save Entries", nil)
message:NSLocalizedString(@"Your entries will be lost", nil)
delegate:self
cancelButtonTitle:NSLocalizedString(@"Cancel", nil)
otherButtonTitles:NSLocalizedString(@"Save", nil), nil];
[alert show];
[alert release];
}
else
{
// Remove rows from quick item entry screen
[[ProductViewInstances shared].quickProductView removeRowsFromtable];
if(didPressHome)
[self popToSpringBoard:YES];
else
[self.navigationController popViewControllerAnimated:YES];
}
}
그래서 내가 다시 누르면 항목이 손실되는지 확인해야합니다. 스프링 보드에 팝업은 화면의 몇 가지를 다시 나타나고 기본적으로 다음과 같은 호출
NSArray *controllers = appDelegate.navigationController.viewControllers;
UIViewController *springboard = [controllers objectAtIndex:2];
[appDelegate.navigationController popToViewController:springboard animated:animated];
을하지만, popViewController 애니메이션 호출은 아무것도하지 않는다 ... 그것은 결코 일어나지 않았다처럼처럼.
Donie
죄송있다 방법 '- (공극) myCustomBack { \t didPressHome = NO; \t [self goBack]; }' – d0n13