stuck at this, seeking advice.
What i did and my Project:
i make a book for children. Every page is a custom ViewController. On every Page i have a button for next and previous Page.
I use the AppDelegate to load the ViewControllers.
My AppDelgate starts with the ViewController1 and when i Press the Button/swipe in ViewController1 it should Load the ViewController2 but nothing happens.
My Code in AppDelegate:
self.view1 = [ViewController1 alloc];
[window addSubview:view1.view];
[window makeKeyAndVisible];
- (void)goToNextPage {
view2 = [ViewController2 alloc];
UIView *current = self.window;
[self.window addSubview:view2.view];
CATransition *animationT = [CATransition animation];
[animationT setDuration:0.5];
[animationT setType:kCATransitionMoveIn];
[animationT setSubtype:kCATransitionFromRight];
[animationT setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[current layer] addAnimation:animationT forKey:@"SwitchToView1"];
NSLog(@"works2");
}
Here my ViewController1:
- (void)addButtonNext {
UISwipeGestureRecognizer *swipeGesture = [[[UISwipeGestureRecognizer alloc] initWithTarget:self action:@selector (buttonClicked:)] autorelease];
swipeGesture.numberOfTouchesRequired = 1;
swipeGesture.direction = (UISwipeGestureRecognizerDirectionLeft);
[self.view addGestureRecognizer:swipeGesture];
NSLog(@"works0");
}
- (void)buttonClicked:(id)sender {
NSLog(@"works1");
AppDelegate* next = [AppDelegate alloc];
[next goToNextPage];
}
My Console says works0 works1 works2.
Any idea?
Thanks in advance
Dont allocate the application delegate
you need to deal with it like this