0

I have an UIViewController named MainViewController. It's frame: I also have an UIView named SingleSearchView which is a subview of MainViewController.

And I add this singleSearchView to the MainViewController:

self.singleSearchView = [[SearchView alloc] initWithFrame:CGRectMake(0, -480, 320, 480)];
[self.view addSubview:singleSearchView];

When I'm trying the following animation to "switch" to the singleSearchView it blocks me from any touch interaction with the singleSearchView

[UIView beginAnimations:@"searchAnimation" context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:1.0f]; 
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self.singleSearchView cache:YES];
[self.view setFrame:CGRectMake(0, 480, 320, 480)];    
[UIView commitAnimations];

I also tried this way:

[UIView animateWithDuration:1.5 delay:0 
                 options:UIViewAnimationOptionAllowUserInteraction 
                     animations:^{
                         [self.view setFrame:CGRectMake(0, 480, 320, 480)];  
                     }
                     completion:nil];

Thanks

3 Answers3

3

From this answer to another question:

Turns out UIView's block animation by default blocks user interaction, and to get around it you need to pass UIViewAnimationOptionAllowUserInteraction as one of the options. Hopefully someone else will have some use of this information as well.

Community
  • 1
  • 1
sergio
  • 68,819
  • 11
  • 102
  • 123
  • Very useful, thanks. I've also noticed that on iOS 4, AllowUserInteraction is off by default. On iOS 5, it's ON by default. – jowie Oct 28 '11 at 16:01
0

You shouldn't try to move self.view. The self.view property is special in the UIVIewControll hierarchy. You should create a subview and animate this one instead...

Pier-Olivier Thibault
  • 3,907
  • 2
  • 33
  • 33
  • Thanks, but I want to make like a "Push" animation the the singleSearchView "pushes" from top the MainViewController view downside the screen –  Aug 03 '11 at 13:04
0

Figured it out!

CATransition* trans = [CATransition animation];
[trans setType:kCATransitionPush];
[trans setDuration:0.5];
[trans setSubtype:kCATransitionFromBottom];

[self.singleSearchView setFrame:CGRectMake(0, 0, 320, 480)];

CALayer *layer = self.view.layer;
[layer addAnimation:trans forKey:@"Transition"];
Groot
  • 13,943
  • 6
  • 61
  • 72