Ios go to next view using a button without using navigation controller - objective-c

just getting started with IOS - worked out a few tutorials -
Everything i have worked with in the tutorials - i have been using the navigation controller to go to the next view when clicking on a button.
well i was having a look at the logos quiz app by aticoD.
i cant see any navigation controller on this app- it has some custom arrow picture, that acts as a back button- but the navigation bar is not visible.
is it using this method ???-
- (void)viewWillAppear:(BOOL)animated {
[self.navigationController setNavigationBarHidden:YES animated:YES];
}
--- you can see on the app, to choose level - you have to swipe -
can anyone give me a few guidelines on how to implement this part. or link me to a tutorial.

you need to set this code
UIViewController *viewController = [[UIViewController alloc] init];
//Animation
CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionMoveIn];
[animation setSubtype:kCATransitionFromRight];
[animation setFillMode:kCAFillModeForwards];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear]];
//animation add to layer.
[[viewController.view layer] addAnimation:animation forKey:#"pushAnimation"];
[[self.navigationViewController.view layer]addAnimation:animation forKey:#"pushAnimation"];
[self.navigationViewController pushViewController:seeAllViewController animated:YES];
for difference kind of animation you just need to change animation Type,subType and fillMode.

Related

animationDidStop method called immediately

I've never had this issue come up before. my animationDidStop method is being called before the animation actually completes. animationDidStart gets called first, but then animationDidStop is called immediately after. I tried to handle this using an animation completion block, but it called the animation completed immediately still. Anybody run across this before? I really could use a bit of help. THANK YOU.
-James
CODE:
-(void) runAnimation {
//Create an animation that rotates the tile
CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:#"transform.rotation"];
[animation setDuration:6];
[animation setFromValue:[NSNumber numberWithFloat:0]];
[animation setToValue:[NSNumber numberWithFloat:0.5*M_PI]];
[animation setDelegate:self];
animation.fillMode = kCAFillModeForwards;
animation.removedOnCompletion = NO;
[[self.view viewWithTag:100].layer addAnimation:animation forKey:#"solutionRotate"];
}
-(void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag
{
if (theAnimation == [[self.view viewWithTag:100].layer animationForKey:#"solutionRotate"]){
//test
NSLog (#"test");
}
}
If the layer is not part of any layer tree then the animation will end immediately since there is nothing to actually animate on screen. Make sure the animated view is added to a visible view hierarchy.

Force NavigationBar's title to animate

I'm developing a navigation system that drills down three steps and then lets you navigate the contents with arrows that actually just change the contents of that view, so technically the navigationcontroller doesn't receive any pop/push, because of that I as soon as I do a
self.navigationItem.title = [[[self.symbol valueForKey:#"section_title"] uppercaseString] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
the title changes as It should but for obvious reasons doen't animate.
Is there a way to force it to animale as if a pop/push action happened?
something like:
self.navigationItem.direction = NavigationDirectionLeft;
self.navigationItem.title = #"Whatevah!";
so that as soon as the title changes it make the old title fades out
in a transition that goes from left to right and the the title fades in, or
way better the new title faded in transitioning from left to right entering
from the left side
[FYI I don't need to support ios versions prior to 5.0, so only 5.0 > :)]
OK, this isn't a perfect solution, but might give you a starting point:
Fading between nav bar titles is fairly simple:
CATransition *fade = [CATransition animation];
fade.type = kCATransitionFade;
fade.duration = 2.0;
[self.navigationController.navigationBar.layer addAnimation: fade forKey: #"fadeText"];
self.navigationItem.title = "new Title";
There are other kinds of "out of the box" transitions you can use to animate the position of the title, so for example:
CATransition *push = [CATransition animation];
push.duration = 2.0;
push.type = kCATransitionPush;
push.subtype = kCATransitionFromRight;
[self.navigationController.navigationBar.layer addAnimation: push forKey: #"pushText"];
self.navigationItem.title = "new Title";
The problem with this is that the whole nav bar moves. To get around this you'll need to find the layer for the title label in the navbar's subviews. This view hierarchy is 'private', so you shouldn't go submitting this code to the store, but like I say… this might give you a starting point.
CATransition *fade = [CATransition animation];
fade.type = kCATransitionFade;
fade.duration = 2.0;
CATransition *move = [CATransition animation];
move.duration = 2.0;
move.type = kCATransitionMoveIn;
move.subtype = kCATransitionFromRight;
UILabel * navBarTitleLabel;
for (UIView * view in self.navigationController.navigationBar.subviews) {
if ([NSStringFromClass(view.class) isEqualToString: #"UINavigationItemView"]) {
navBarTitleLabel = view.subviews.firstObject;
break;
}
}
[navBarTitleLabel.layer addAnimation: fade forKey: #"fadeText"];
[navBarTitleLabel.layer addAnimation: move forKey: #"moveText"];
self.navigationItem.title = newTitle;
You might find that you need to removeAllAnimations from the layer once they're complete. I didn't get a chance to fully test it all out.
Try setting a UIView as self.navigationItem.titleView and then create a UILabel and add it as title. When you want to animate, animate this Label over this UIView and add a new UILabel and animate that to replace this. You can use some block based animations for this.
For eg:-
[UIView animateWithDuration:0.5
delay:1.0
options: UIViewAnimationCurveEaseOut
animations:^{
label.frame = labelFrame;
}
completion:^(BOOL finished){
NSLog(#"Done!");
}];

How to make an Auto-hidden Toolbar in iPad app?

I'm new to Xcode development and have a (hopefully simple) question:
I want to write an iPad App which shows a document in an UIPageView and in addition shows a bar at the bottom to navigate in the document (i.e. with buttons on it for each chapter).
This bar should automatically hide (except a small grip) while switching pages and show up when pressing (or dragging) the grip.
The bar should overlap the PageView (PageView not resized).
I already finished the PageView (based on the template in XCode) but don't know the best way to implement the bottom-bar.
Any suggestions?
Examples welcome.
to show
[self doSingleViewHideAnimation:myToolBar:kCATransitionFromBottom];
-(void)doSingleViewHideAnimation:(UIView*)incomingView:(NSString*)animType
{
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:animType];
[animation setDuration:0.5];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[incomingView layer] addAnimation:animation forKey:kCATransition];
incomingView.hidden = YES;
}
To hide
[self doSingleViewShowAnimation:myToolBar:kCATransitionFromTop];
-(void)doSingleViewShowAnimation:(UIView*)incomingView:(NSString*)animType
{
CATransition *animation = [CATransition animation];
[animation setType:kCATransitionPush];
[animation setSubtype:animType];
[animation setDuration:0.5];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
[[incomingView layer] addAnimation:animation forKey:kCATransition];
incomingView.hidden = NO;
}
Make a new view.
Put a tap gesture recognizer on it
When it's tapped use UIView animations to slide it in or out.
what i found is and also working for me is as under
first i put one toolbar in xib like this
then create one IBOutlate in .h file like this
#property (retain, nonatomic) IBOutlet UIToolbar *toolbar;
then attach it to the toolbar in xib like this
then i create one UITapGestureRecognizer in .m file as below
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(handle_Tap:)];
tap.numberOfTapsRequired = 1;
tap.numberOfTouchesRequired = 1;
[self.view addGestureRecognizer:tap];
and the handle_Tap: method is as follow in .m file for sure
-(void)handle_Tap:(id)sender
{
self.toolbar.hidden = !self.toolbar.hidden;
}
that's all i need to do and the toolbar is appeared when taped and disappeared when tapped again whola!!
It's done thanks to Apple Documents
Happy Codding !!
Enjoy Day :)

Other transition styles using segue

I've started programming for iOS only for a few weeks, so I don't know how it was done before, but I'd like to use other transition styles for my segues. Like the one where the screen flips, giving you the impression that the destination view controller was on the back of the first one. I suppose I have to subclass UIStoryboardSegue, but apart from that, I have no idea where to go from there.
Thanks for your time!
You can use CATransition within a custom Segue to achieve any kind of transition. Here is sample code.
-(void)perform {
__block UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
__block UIViewController *destinationController = (UIViewController*)[self destinationViewController];
CATransition* transition = [CATransition animation];
transition.duration = .25;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
transition.subtype = kCATransitionFromLeft; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom
[sourceViewController.navigationController.view.layer addAnimation:transition
forKey:kCATransition];
[sourceViewController.navigationController pushViewController:destinationController animated:NO];
}
You visit this link for more details http://blog.jambura.com/2012/07/05/custom-segue-animation-left-to-right-using-catransition/
Ok I didn't look far enough. Select the segue you want to customize, and there's a "transition" style option.

Replacing a NSSplitView subview with Core Animation

I'm trying to figure out how to animate switching (replacing) subviews in a vertically-configured, 2-view NSSplitView. I've got it semi-working using the following methods in my NSSplitView subclass:
To set up the animation:
- (void)awakeFromNib {
// set delegate
[self setWantsLayer:YES];
CATransition *transition = [CATransition animation];
[transition setType:kCATransitionPush];
[transition setSubtype:kCATransitionFromBottom];
[transition setDuration:1.0];
[self setAnimations:[NSDictionary dictionaryWithObject:transition
forKey:#"subviews"]];
}
And to perform it:
- (void)replaceRightView:(NSView *)newView animated:(BOOL)animate {
NSRect currentSize = [[[self subviews] objectAtIndex:1] frame];
[newView setFrame:currentSize];
if (animate) {
[[self animator] replaceSubview:[[self subviews] objectAtIndex:1]
with:newView];
} else {
[self replaceSubview:[[self subviews] objectAtIndex:1]
with:newView];
}
}
However, this code has the effect of pushing the entire NSSplitView off, rather than just the subview on the right side of the split.
Is there a way to animate just the subview transition? Perhaps I'm using the wrong animation key ("subviews")? Other animation methods would be fine too.
Thanks!
It's probably not the cleanest way, but I ended up using an NSView 'container' subclass with custom addSubview: and replaceSubview:withView: methods that modify the new subview's frame to match the container view's frame, which is then structured into the NSSplitView subview I wanted to animate. I then setup the CATransition on the container view, and everything worked as I wanted.