UIActivityIndicator does not animate - objective-c

- (void) viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
self.connectionIndicator = [[[UIActivityIndicatorView alloc]
initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray] autorelease];
[self.view addSubview:connectionIndicator];
[self.connectionIndicator setCenter:CGPointMake(self.view.frame.size.width/2, 15)];
[connectionIndicator startAnimating];
}
The spinner shows up frozen, and does not start animating.
Edit: Okay I figured out the cause but yet to find a solution.
This view controller is pushed into navigation controller stack through a page curl-up transition:
ServerHandshakeViewController *shvc = [[ServerHandshakeViewController alloc] initWithHost:h];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[self.navigationController pushViewController:shvc animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[shvc release];
Removing the above curl-up transition like below solves the spinner freeze problem.
ServerHandshakeViewController *shvc = [[ServerHandshakeViewController alloc] initWithHost:h];
[self.navigationController pushViewController:shvc animated:NO];
[shvc release];
But then, what if I want to retain my curl-up page transition?

You could try using the block method where you can specify animation options. UIViewAnimationOptionAllowAnimatedContent is the option which should free up the spinner.
[UIView transitionWithView:self.navigationController.view
duration:1.0
options:UIViewAnimationOptionAllowAnimatedContent | UIViewAnimationTransitionCurlUp | UIViewAnimationOptionCurveEaseInOut
animations:^{[self.navigationController pushViewController:shvc animated:NO];}
completion:nil];

Related

Adding time delay to flip animation on navigating view

I have a button 'filter' on left side on navigation bar. On clicking it I want flip animation with flip delay of 1.5 second while switching to the next view. How to add the code for that?
I am working with this navigation code:
FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;
[self.delegate pushViewController:vc animated:UIViewAnimationTransitionFlipFromLeft];
[vc release];
Now I want a flip delay of 1.5 seconds on view switch by button. I have tried some code but it's not giving me the desired result.
Try this
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:1.5];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight
forView:self.navigationController.view cache:NO];
[self.navigationController pushViewController:vc animated:YES];
[UIView commitAnimations];
[vc release];
taken from How to do the flip animation between two UIViewControllers while clicking info button?
Other way:
MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[super pushViewController:nextView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}];
I get this from How to change the Push and Pop animations in a navigation based app
Use this for delay the push animation:
FilterViewController *vc = [[FilterViewController alloc] init];
vc.delegate = self;
[self performSelector:#selector(callViewController:) withObject:vc afterDelay:1.5];
-(void)callViewController:(FilterViewController*)vc{
[self.delegate pushViewController:vc animated:UIViewAnimationTransitionFlipFromLeft];
[vc release];
}

Flip transition between storyboard view controllers not working

I'm having a lot of trouble setting a flip transition between storyboards. The app crashes when the method below is called. I'm getting the error message:
[NSPathStore2 setView:]: unrecognized selector sent to instance...
This is my code:
- (void)advanceToNextViewController {
humptyDumptyViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:#"firstStoryVC"];
/*
[self.navigationController pushViewController:controller animated:YES];
*/
[UIView beginAnimations:#"animation" context:nil];
[self.navigationController pushViewController:controller animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
}
I'd appreciate any help with this.
Since you are using storyboard. This is more accurate, try this:
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *vc = [sb instantiateViewControllerWithIdentifier:#"firstStoryVC"];
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:vc animated:YES completion:NULL];
But be sure to name your view's identifier "firstStoryVC" otherwise it will crash and wont work.
Then when you want to dimiss the view:
[self dismissModalViewControllerAnimated:YES];
Try this one , it will give you full control over timings and animation.
humptyDumptyViewController *controller = [self.storyboardinstantiateViewControllerWithIdentifier:#"firstStoryVC"];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:controller animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];

iOS transition animation for pushViewController

I have an AppDelegate, which owns a window, and from there on, A main view, from which when I go to the next view, I push the new view in order to use the same Navigation Controller and toolbar:
- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
{
self.appview = [[AppointmentView alloc] initWithNibName:#"AppointmentView" bundle:[NSBundle mainBundle]];
#synchronized(self.MahAppntmnts){ // Set the view's appointment
[appview setMyAppointment:[[MahAppntmnts MyAppointments] objectAtIndex:indexPath.section]];
}
[super addChildViewController:self.appview];
AppDelegate *del = (AppDelegate *)[UIApplication sharedApplication].delegate;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[del.navigationController pushViewController:self.appview animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
}
Now this works fine for switching views, but when I'm trying to go back, I get the same boring flip transition.
I tried setting on my AppView's viewWillDissapear delegate method:
-(void) viewWillDisappear:(BOOL)animated
{
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0.375];
[self.navigationController popViewControllerAnimated:NO];
[UIView commitAnimations];
[super viewWillDisappear:animated];
}
This seems to work for when I go back to the previous view, but when I try to transition to new views (using the same method as before) they either not appear, or I flip by to the same view. So I'm guessing that this code should not be on viewWillDissapear, or that I am doing something wrong...
Well I found the solution, problem was my miss-conception to "whom" the animation belonged to. I added the code found in viewWillDissapear (located in the pushed view), to the viewWillAppear delegate of the view that did the pushing in the first place (the code found in accessoryButtonTappedForRowWithIndexPath), so that the controlling view initiates the animation when pushing another view, and when another view navigates back to it, the reverse animation is displayed. Solved all problems and works like a charm.

View slides up instead of curling with Model View Controller

SignView *tempVC = [[SignView alloc] initWithNibName:#"SignView" bundle:Nil];
[UIView beginAnimations:nil context:nil];
[UIView setAnimationTransition: UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationDelay:0.5f];
[UIView setAnimationDuration:2.0f];
[UIView commitAnimations];
[self presentModalViewController:tempVC animated:YES];
[tempVC passDataWithString:button2.titleLabel.text andColor:currentlySelectedColor isNightModeOn:nightMode.on];
The view slides up instead of Curling up.
What am I doing wrong?
To set the transition style of a modal view controller, set it's modalTransitionStyle property.
self.modalTransitionStyle = UIModalTransitionStylePartialCurl;
Also note that some transition styles don't look right on the simulator, but should be fine on the device.

Is it possible to hide a UIToolbar with an animation?

I know this code is available to UINavigationController only.
[self.navigationController setNavigationBarHidden:YES animated:YES];
An example using blocks. This will hide a toolbar at the top of an iPad screen.
[UIView animateWithDuration:.7
animations:^(void)
{
CGRect toolbarFrame = self.toolbar.frame;
toolbarFrame.origin.y = -44; // moves iPad Toolbar off screen
self.toolbar.frame = toolbarFrame;
}
completion:^(BOOL finished)
{
self.toolbar.hidden = YES;
}];
Here is the Code:
[UIView beginAnimations:#"hideView" context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:toolBar cache:YES];
toolbarFrame.origin.y = 380;
toolBar.frame = toolbarFrame;
[UIView commitAnimations];
you can modify the toolBar 'y' origin.