문제

나는 양쪽에 두 개의 뷰가있는 중심보기가있는 앱이 있습니다. 왼쪽과 오른쪽으로 왼쪽과 오른쪽에서 왼쪽과 오른쪽에서 왼쪽과 오른쪽으로 내비게이션 막대 버튼이 두 개를 원합니다.

PushViewController : NavigationController의 메소드를 사용하여 새 뷰를 푸시하여 뷰를 변경하면 뷰가 오른쪽에서 미끄러 져 들어가는 것으로 보입니다. 왼쪽에서 미끄러 지도록 이것을 변경하려면 어떻게합니까?

도움이 되었습니까?

해결책

내비게이션 컨트롤러를 사용하는 대신보기를 움직입니다.

CGRect inFrame = [currentView frame];
CGRect outFrame = firstFrame;
outFrame.origin.x -= inFrame.size.width;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];

[newView setFrame:inFrame];
currentView setFrame:outFrame];

[UIView commitAnimations];

다른 팁

ViewController를 푸시 할 때 변경 애니메이션 방향을 수행했습니다. 여기에서 애니메이션 유형을 변경할 수 있습니다 Animation setsubtype : kcatransitionfromright];

 ViewController *elementController = [[ViewController alloc] init];

// set the element for the controller
ViewController.element = element;


// push the element view controller onto the navigation stack to display it

CATransition *animation = [CATransition animation];
[[self navigationController] pushViewController:elementController animated:NO];
[animation setDuration:0.45];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromRight];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionDefault]];
[[elementController.view layer] addAnimation:animation forKey:@"SwitchToView1"];

[elementController release];

UinavigationControllers에서 슬라이딩 방향을 명시 적으로 정의 할 수 있다고 생각하지 않습니다. 당신이 할 수있는 것은 내비게이션 스택에서 현재보기를 팝하여 사전보기를 보여주는 것입니다. 그러나 현재 뷰에서 수행하는 작업에 따라 다른 뷰 컨트롤러가 나타나려면 복잡 할 수 있습니다.

워크 플로가 너무 복잡하지 않은 경우 현재 뷰 컨트롤러에서 이전 뷰 컨트롤러에 대한 참조를 사용할 수 있습니다. 현재보기에서 수행하는 작업 (테이블보기 셀 선택)에 따라 이전보기 컨트롤러에 필요한 데이터를 변경 한 다음 호출 할 수 있습니다.

[self.navigationController popViewController];

또는 올바른 방법이 무엇이든 (나는 그것이 어떻게되는지에 가깝다고 생각합니다). 그러면 원하는 애니메이션으로 Nav Stack을 아래로 이동할 수 있습니다. Nav Stack에 수많은 뷰가있는 경우 작동합니다.

리드 올슨의 말에 : 하나의 버튼 만 연결해야합니다.이 버튼은 슬라이드를 동일한 방법으로 시작하고 뷰가 표시되거나없는 경우 추적하는 부울을 추가해야합니다. 원점을 올바르게 설정하기 만하면됩니다.

- (IBAction)slideMenuView 
{
  CGRect inFrame = [self.view frame];
  CGRect outFrame = self.view.frame;

  if (self.viewisHidden) {
    outFrame.origin.x += inFrame.size.width-50;
    self.viewisHidden = NO;
  } else {
    outFrame.origin.x -= inFrame.size.width-50;
    self.viewisHidden = YES;
  }
  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:0.5];
  [self.menuView setFrame:inFrame];
  [self.view setFrame:outFrame];
  [UIView commitAnimations];
}

"Pointy"유형 버튼을 얻으려면 다른 방법을 사용해야합니다.

AppDelegate에서 :

UITableViewController *first = [[RootViewController alloc] initWithStyle:UITableViewStylePlain];
UITableViewController *second = [[SomeOtherViewController alloc] initWithStyle:UITableViewStylePlain];

NSArray *stack = [NSArray arrayWithObjects: first, second, nil];

UINavigationController *nav = [[UINavigationController alloc] init];
[nav setViewControllers:stack animated:NO];

rtlnavigationcontroller : uinavigationcontroller를 상속하고 이러한 함수를 덮어 쓸 수 있습니다.

 - (void) pushViewController:(UIViewController *)viewController animated:(BOOL)animated
 {
     DummyViewController*dvc = [[DummyViewController alloc] init];
     [super pushViewController:viewController animated:NO];
     [super pushViewController:dvc animated:NO];
     [dvc release];
     [super popViewControllerAnimated:YES];
}

그리고

- (UIViewController *)popViewControllerAnimated:(BOOL)animated
{
 UIViewController *firstViewController = [super popViewControllerAnimated:NO];
 UIViewController *viewController = [super popViewControllerAnimated:NO];
 [super pushViewController:viewController animated:animated];
 return firstViewController;
} 

그리고 신청 대의원 :

navCon = [[RTLNavigationController alloc] init];

rootViewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
rootViewController.contextDelegate = self;

DummyViewController *dvc = [[DummyViewController alloc]init];
[navCon pushViewController:dvc animated:NO];
[dvc release];

[navCon pushViewController:rootViewController animated:NO];
[self.window addSubview:navCon.view];

밀기는 왼쪽에서 오른쪽으로 오른쪽에서 왼쪽으로 튀어 나옵니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top