I'm using a custom flip transition during a push transition.
I use this code and the flip is good:
UIStoryboard* sb = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
MyViewController* myViewController = [sb instantiateViewControllerWithIdentifier:
#"MyViewController"];
[UIView transitionWithView:self.navigationController.view
duration:0.75
options:UIViewAnimationOptionTransitionFlipFromRight
animations:^{
[self.navigationController pushViewController:myViewController animated:NO];
}
completion:nil];
The problem is during the transition. I have a kind of shadow on all the window view. I can change the color but the shadow stays. An example with a red background ([UIColor RedColor]):
Thank you
Related
I'm using UINavigation and UIPageView controller in a UIViewController. I have 3 buttons and here is my code :
- (IBAction)StartButtonClicked:(id)sender {
NSLog(#"start button pressed");
[_Timer invalidate];
_Timer = nil;
dispatch_async(dispatch_get_main_queue(), ^{
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
CardViewController* controller = [storyboard instantiateViewControllerWithIdentifier:#"CardViewController"];
[self.navigationController pushViewController:controller animated:NO];
}
}
- (void)pageViewController {
self.pvc = [[UIPageViewController alloc] initWithTransitionStyle:UIPageViewControllerTransitionStyleScroll navigationOrientation:UIPageViewControllerNavigationOrientationHorizontal options:nil];
self.pvc.view.frame = self.view.bounds;
[self.view addSubview:self.pvc.view];
[self.pvc setViewControllers:#[[viewControllerArray1 objectAtIndex:0]] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
}
- (IBAction)rightButtonPressed:(id)sender {
[self pageViewController];
[self.pvc setViewControllers:#[[viewControllerArray1 objectAtIndex:1]] direction:UIPageViewControllerNavigationDirectionForward animated:YES completion:nil];
}
- (IBAction)leftButtonPressed:(id)sender {
[self pageViewController];
[self.pvc setViewControllers:#[[viewControllerArray1 objectAtIndex:2]] direction:UIPageViewControllerNavigationDirectionReverse animated:YES completion:nil];
}
When I click on right button and came back to this view controller my start button's push view not working.
Please check the answer .
iOS - Push viewController from code and storyboard
Don't initialize Storyboard always,
UIStoryboard* storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
You can set the rootViewController from the UtoryBoard itself.
Set initialViewController as a UINavigationController and Set the FirstViewController as RootViewController.
Edit :
For Push use the below code,
CardViewController* controller = [storyboard instantiateViewControllerWithIdentifier:#"CardViewController"];
[self.navigationController pushViewController:controller animated:NO];
and Back. If use the default backButton not need to write any code.
If use are using custom backButton,
[self.navigationController popViewController];
Check 2 things,
Your storyboard identifier is correct.
The root view have navigation Controller.
Your StoryBoard should be like this,
I have three screens Google Map,Settings,Login.By default google map is visible.When i want to show settings screen then i don't move to settings view controller i just add "Settings"screen as subview of "Google Map"Screen.
menusettings=[self.storyboard instantiateViewControllerWithIdentifier:#"SET"];
[menusettings.view setFrame:CGRectMake(0, 0, 700,600)];
[self.view addSubview:menusettings.view];
After upadating settings i move to login screen
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"iPhone" bundle:nil];
UINavigationController *ppc = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:#"LOGIN"];
[self presentViewController:ppc animated:true completion:nil];
But settings screen is still behind login screen but it is not removed. I tried two scenerios
1.I tried to remove settings view before moving to login screen
[self.view removeFromSuperview];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"PRG_iPhone" bundle:nil];
UINavigationController *ppc = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:#"LOGIN"];
[self presentViewController:ppc animated:true completion:nil];
but it does not move to login screen.
2.When i tried removing settings view after moving to login screen
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"PRG_iPhone" bundle:nil];
UINavigationController *ppc = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:#"LOGIN"];
[self presentViewController:ppc animated:true completion:nil];
[self.view removefromsuperview];
Then it moved to login screen but does not remove settings view
So i thought why not remove Google Map Screen's subview which is setting screen from login screen but i don't know how can i remove a google map screen child view which is settings screen.Please guide how to do this ?
Change this
[self.view removeFromSuperview];
to and try
[menusettings.view removeFromSuperview];
update
[menusettings.view removeFromSuperview];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"PRG_iPhone" bundle:nil];
UINavigationController *ppc = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:#"LOGIN"];
[self presentViewController:ppc animated:true completion:nil];
Choice-1
[self.view.subviews makeObjectsPerformSelector: #selector(removeFromSuperview)];
choice-2
Initially assign the tag for your View for e.g
menusettings=[self.storyboard instantiateViewControllerWithIdentifier:#"SET"];
[menusettings.view setFrame:CGRectMake(0, 0, 700,600)];
menusettings.tag = 5; //you can use any number you like
[self.view addSubview:menusettings.view];
Remove
UIView *Remove = [self.view viewWithTag:5];
[Remove removeFromSuperview];
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"PRG_iPhone" bundle:nil];
UINavigationController *ppc = (UINavigationController *)[storyboard instantiateViewControllerWithIdentifier:#"LOGIN"];
[self presentViewController:ppc animated:true completion:nil];
Choice-3
for (UIView *subVie in self.view.subviews)
{
if (subVie.tag == 5)
{
[subVie removeFromSuperview];
}
}
I am pushing a view controller whilst animating it so it flips. However, the animation is only applied to the view beneath the navigation bar, so the navigation bar hides for a few seconds then suddenly appears again. How can I apply the animation to the entire view, including the navigation bar?
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"OverviewiPad" bundle:nil];
OverviewViewController *overviewVC = [sb instantiateViewControllerWithIdentifier:#"OverviewViewController"];
overviewVC.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.75];
[self.navigationController pushViewController:overviewVC animated:NO];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.navigationController.view cache:NO];
[UIView commitAnimations];
I tried to pass an image to a view controller like following,
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main_iPad" bundle:nil];
CropViewController *vc = (CropViewController*)[storyboard instantiateViewControllerWithIdentifier:#"CropViewController"];
vc.imageView.image = [UIImage imageWithData:jpegData];
// present
[self presentViewController:vc animated:YES completion:nil];
using this it's presenting to the desired view controller well. But the image that I've set, it's not added to the image view. Is there any way to fix this? Why is this happening?
Thanks in Advance1
Should be:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main_iPad" bundle:nil];
CropViewController *vc = (CropViewController*)[storyboard instantiateViewControllerWithIdentifier:#"CropViewController"];
// present
[self presentViewController:vc animated:YES completion:(^{
vc.imageView.image = [UIImage imageWithData:jpegData];
})];
VC's view hierarchy was not set up
I am trying to create a scale animation for my view controller presentation
what i have is
UIViewController *vc =[[UIViewController alloc]initWithNibName:#"nextVC" bundle:[NSBundle mainBundle]];
[vc willMoveToParentViewController:self];
[self addChildViewController:vc];
[self transitionFromViewController:currentViewController toViewController:vc duration:2 options:0 animations:^(void){
vc.view.layer.anchorPoint = currentViewController.view.frame.origin;
vc.view.transform = CGAffineTransformMakeScale(1.0f, 1.0f);
vc.view.frame = currentViewController.view.frame;
}completion:^(BOOL finished){
[vc didMoveToParentViewController:self];
}];
now this code works, the view controller is presented.
but instead of doing the right scale i want, it comes flying in from the bottom right corner.
how do i make it sort of unfold from the top margin to the bottom margin