Probleme mit pushViewController!! Helfen

tabBarController = [[UITabBarController alloc] init];   //Create a tab bar  
view1 = [[View1 alloc] init];   //Create the first view
UINavigationController *navigationController1 = [[UINavigationController alloc] initWithRootViewController:view1];
navigationController1.navigationBar.tintColor =[UIColor blackColor];
view2 = [[View2 alloc] init];   //create the second view
UINavigationController *navigationController2 = [[UINavigationController alloc] initWithRootViewController:view2];
navigationController2.navigationBar.tintColor =[UIColor blackColor];
tabBarController.viewControllers = [NSArray arrayWithObjects:navigationController1, navigationController2,nil];
[window addSubview:tabBarController.view];
[window makeKeyAndVisible];

Den obigen code sind aus meiner appDelegate-Klasse (applicationDidFinishLaunching). View1 und Ansicht2 sind UIViewController. Dies ist, wie ich ursprünglich das design für meine apps, die die apps hat zwei Registerkarten (view1 und ansicht2). Der code unten, das umzusetzen, was passieren in View1, wenn der Benutzer nach Links oder rechts ziehen.

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"I am in touches began  methods");

UITouch *touch = [touches anyObject];
gestureStartPoint = [touch locationInView:self.view];

}


- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [touches anyObject];
CGPoint currentPosition = [touch locationInView:self.view];

CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);
CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);

if (deltaX >= kMinimumGestureLength && deltaY <= kMaximumVariance) {
    //Set Animation Properties
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration: 1];

    if(gestureStartPoint.x > currentPosition.x){    //I am trying to move right

        ViewControllerTemplate *newView = [[ViewControllerTemplate alloc] initWithNibName:@"ViewControllerTemplate" bundle:nil];
        //Transition spin right
        [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
        //Push OnTo NavigationController
        [self.navigationController pushViewController:newView animated:YES];        
    }
    else {  //I am trying to move left
        if([viewDelegate getCurrentViewID] > 0){    //At view 0, should not pop anymore view
            //Transition Spin left
            [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
            [self.navigationController popViewControllerAnimated:YES];
        }
    }
    [UIView commitAnimations];
}
}

Ziemlich viel, es ist einfach zu sagen, dass, wenn der Benutzer nach rechts streichen, wird es eine neue Ansicht erstellen (ViewControllerTemplate) und pushViewController, und wenn der Benutzer swipe Links, popViewController. Da ich jedoch meine Meinung ändern und wollen nicht, dass zur Umsetzung der tab-Leiste. So ändere ich meinen code in applicationDidFinishLaunching in appDelegate, um diese unten und der pushViewController in touchesMoved in View1.m aufhören arbeiten. Ich bin sicher, dass es man es, aber wenn es pushViewController der newView, nichts passieren. Ich fühle mich wie wenn ich nahm den UINavigationController, meine Sicht sind nicht push auf den Stapel mehr richtig. Keine Ahnung warum, und wie man es beheben

view1 = [[View1 alloc] init];
[window addSubview:View1.view];
InformationsquelleAutor Thang Pham | 2010-02-17
Schreibe einen Kommentar