1
-(IBAction) takeNextStep : (id) sender 
{ 
    SecondViewController *varSecondViewController =[[SecondViewController alloc] initWithNibName:@"SecondViewController" bundle:nil]; 
} 

wie ich es von dem Standard von links nach rechts (Vorwärts) Schiebe ändern nach rechts (rückwärts) nach links , wie ich eine benutzerdefinierte Schaltfläche haben so verwaltet ich meine benutzerdefinierte Schaltfläche programmieren, um die Wurzel zu gehen zurück aber es gleitet von rechts nach links und verursacht dadurch Verwirrung beim BenutzerÄndern der Animation von links nach rechts und von rechts nach links für den Zurück-Button! Navigation

danke!

+0

hallo im hinblick auf probleme für diese, nicht in der lage, meine zweite ansicht zurück zur ersten ansicht zu gleiten! derzeit: Folien von links nach rechts (Going fwd) was ich brauche: Folien von rechts nach links –

Antwort

2

Sie so etwas wie dieses verwenden könnte ...

(Benötigt < Quartz/QuartzCore.h>)

- (void)switchTwoViews:(UIView *)view1 otherView:(UIView *)view2 direction:(int)directionRL{ 
    view2.bounds = CGRectMake(0, 0, 480, 320); 
    visibleView = view2; 
    // remove the current view and replace with view1 
    [view1 removeFromSuperview]; 
    [currentOptionsView addSubview:view2]; 

    // set up an animation for the transition between the views 
    CATransition *animation = [CATransition animation]; 
    [animation setDuration:0.5]; 
    [animation setType:kCATransitionPush]; 
    if (directionRL == 0) { 
     [animation setSubtype:kCATransitionFromRight]; 
    } else { 
     [animation setSubtype:kCATransitionFromLeft]; 
    } 

    [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

    [[currentOptionsView layer] addAnimation:animation forKey:@"SwitchToView"]; 
} 

, die eine benutzerdefinierte Funktion ist, die eine Ansicht von rechts gleitet nach links (Richtung = 0) oder umgekehrt (Richtung = 1).

Probieren Sie es aus. Genießen.

+0

danke! wird es geben –

+0

Es gibt sechs Fehler kCATransitionX ... Können Sie bitte infor, was alle Header zusammen mit QuartzCore enthalten sein müssen. –

+0

Es sollte nur #import ... sein. Nicht sicher, ob UIKit notwendig ist. –

4

Ähnlich wie Xen Antwort, Download the sample code here.

// get the view that's currently showing 
UIView *currentView = self.view; 
// get the the underlying UIWindow, or the view containing the current view 
UIView *theWindow = [currentView superview]; 

UIView *newView = aTwoViewController.view; 

// remove the current view and replace with myView1 
[currentView removeFromSuperview]; 
[theWindow addSubview:newView]; 

// set up an animation for the transition between the views 
CATransition *animation = [CATransition animation]; 
[animation setDuration:0.5]; 
[animation setType:kCATransitionPush]; 
[animation setSubtype:kCATransitionFromRight]; 
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]]; 

[[theWindow layer] addAnimation:animation forKey:@"SwitchToView2"]; 
Verwandte Themen