I have an animation done over the keyWindow of the app.
[UIView beginAnimations:kAnimationLogin context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:window_ cache:NO];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[window_ addSubview:splitViewController_.view];
[UIView commitAnimations];
[loginViewController_.view removeFromSuperview];
This works ok. Then, if the user logouts, the transition is the reverse
[UIView beginAnimations:kAnimationLogout context:nil];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:window_ cache:NO];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0];
[window_ addSubview:loginViewController_.view];
[UIView commitAnimations];
[splitViewController_.view removeFromSuperview];
Here is the problem. Now, loginViewController_ and splitViewController_ don't receive the orientation notifications. Why?
Well, it's not a great solution but I've found a way to avoid that problem. First of all, I think that the problem comes because, while animation, both view controllers receives the orientation notifications while, I guess, adding and removing to and from the window and raises the problem. I don't know exactly if it's an issue related to view hierarchy (I guess it's correct but I'm not sure) or not.
So, the solution I use is to put the LoginViewController as a ModalViewController of SplitViewController, that is the main controller, and use a FlipHorizontal transition while showing.
That solves the problem.
Related
After following countless tutorials and trying different methods, my iAd banners simply do not show while running the simulation, and if they do, they fade quickly without displaying anything.
This is the current code I am using to display an iAd banner:
-(void)bannerViewDidLoadAd:(ADBannerView *)banner {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations]; }
-(void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations]; }
I have delegated the banner to the view, have imported the iAd framework in the viewcontroller.h, and followed all other necessary steps. However, while launching the simulator (in any phone size) an ad does not appear, even after waiting a considerable amount of time. I have no errors or other indications that I have done something wrong, and have been stuck on this for a while. Why won't the banner show?
I'm trying to create an unwind segue with the page curl animation. I've followed a tutorial I found only to have the destination view controller call segueForUnwindingToViewController to return an instance of my custom segue class. However, at best it just instantly changes to the appropriate view without a delay or any animation.
Any help would be appreciated.
The contents of perform:
[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationOptionTransitionCurlUp
animations:^{}
completion:^(BOOL finished){
[destinationViewController.view removeFromSuperview];
[sourceViewController dismissViewControllerAnimated:NO completion:NULL];
}];
I am trying to get a similar result to the post that is shown here: https://stackoverflow.com/questions/28866171/place-iad-over-a-uitabbar
So this is what i did to achieve this:
One side question here: Is it normal that i can't drag the banner all the way?
And using this i get this result:
Nevermind that the iAd dont show. But my real question is why is not the TableView appearing beneath the iAd so i can get the same result as the on in the post? What can i do to make this work?
Thank you all!
Ok i solved this with some more researching and testing.
FIRST OF ALL. You DONT need to use a UITableView inside a UIViewController to make this work. This can be done by having a subclass of UITableViewController which i had from start but i thought i needed to change.
Anyway Here is the code:
- (void)viewDidLoad
{
[super viewDidLoad];
self.canDisplayBannerAds = YES;
}
- (void)bannerViewDidLoadAd:(ADBannerView *)banner
{
banner.frame = CGRectOffset(banner.frame, 0, banner.frame.size.height);
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:1];
[UIView commitAnimations];
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1];
[banner setAlpha:0];
[UIView commitAnimations];
}
NOTE this method is used when i am not placing an iAd in the storyboard. There is no need to do that when using this method. So no need to think about putting delegates etc..
In the typical viewcontroller transition both views, the disappear and appear view are moving, but now I want to create a custom animation where you throw the event to change of view, the view that will disappear, just hide without transition and animation, and the view will appear continue with the same transition.
then the problem here is I have navigation bar and I don't know, how can I create a custom transition of navigation bar?,
can you help me to know how to change or remove the transition of navigation controller.
I've try it but it only add other transition and don't remove the base transition.
For Push:
MainView *nextView = [[MainView alloc] init];
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[self.navigationController pushViewController:nextView animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
}];
For Pop:
[UIView animateWithDuration:0.75
animations:^{
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:transition forView:self.navigationController.view cache:NO];
}];
[self.navigationController popViewControllerAnimated:NO];
any ideas? thanks :D
You can just use add as subview and have title bar to mimic like navigation controller.
MainView *nextView = [[MainView alloc] init];
//setup frame
nextView.view.frame = xxx;
[self.view addSubview:nextView.view];
Remove using [nexView.view removeFromSuperView];
OR
Just add some view above your current view with default hidden and set hidden NO on some action or call bringSubviewFront method if you want to keep view below and bring in front on some action.
I find myself in need of access to a viewcontroller from its view.
Here is the method
-(void)changePageView:(UIViewController*)newviewcont withtransitiontype:(int)t andtransitionspeed:(int)s
{
//Remove whatever view is currently loaded at index 0, this index is only to be used by "page" views
UIView *oldview = [self.view.subviews objectAtIndex:0];
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:s];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[newviewcont viewWillAppear:YES];
//[oldview viewWillDisappear:YES];
[oldview removeFromSuperview];
[self.view insertSubview:newviewcont.view atIndex:0];
//[oldview viewDidDisappear:YES];
[newviewcont viewDidAppear:YES];
}
Basically, I am trying to write a generic view switch method that is called by the root controller to swap out subviewcontorllers views from the rootcontrollers view.
I pass in a subviewcontroller and am able to remove the current subview. But in order to do proper view switching animation i need access to the current views view controller. Is this the wrong approach and can it be done?
I added a member to the rootcontroller that hold onto the current sub view controller (currentController) and refers to it when a controller swap is done
-(void)changePageView:(UIViewController*)newviewcont withtransitiontype:(int)t andtransitionspeed:(int)s
{
[UIView beginAnimations:#"View Flip" context:nil];
[UIView setAnimationDuration:s];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];
[newviewcont viewWillAppear:YES];
[self.currentController viewWillDisappear:YES];
[self.currentController.view removeFromSuperview];
[self.view insertSubview:newviewcont.view atIndex:0];
[self.currentController viewDidDisappear:YES];
[newviewcont viewDidAppear:YES];
[UIView commitAnimations];
self.currentController = newviewcont;
}
The changeView() method belongs in the viewcontroller. It would solve you problem of having the view knowing about it's controller (which it shouldn't) and it makes more sense.
Also unless you are doing something fancy in changeView() that can't be done using the methods in a UIViewController object then you should just use it instead, if it is neccesary to implement your own view switching method then you can extend UIViewController instead of implemtning part of the view controlelr in your view.
my 2 cents :)
I believe your approach is wrong. You should look into UINavigationController I believe.