help me please. How can I show another view controller after dismissing the existing one? here is my code:
- (void)matchmakerViewControllerWasCancelled:
(GKMatchmakerViewController *)viewController{
[self dismissModalViewControllerAnimated:YES];
ViewController *Vc = [[ViewController alloc]init];
[self presentModalViewController:Vc animated:YES];
}
My code doesn't work. Help me please. If i wrote NSLog after dismissingModalViewController, it shows me that NSLog, but ViewController won't show. thanks
[self dismissModalViewControllerAnimated:YES]; has been deprecated. Try doing:
- (void)matchmakerViewControllerWasCancelled:
(GKMatchmakerViewController *)viewController{
[self dismissViewControllerAnimated:YES completion:^{
ViewController *Vc = [[ViewController alloc]init];
[self presentViewController:Vc animated:YES completion:^{}];
}];
}
Simply check this
[self dismissModalViewControllerAnimated:NO];
Nextview *sec = [[Nextview alloc] initWithNibName:#"Nextview" bundle:nil];
[self presentModalViewController:sec animated:YES];
[sec release];
Hope this works.
Related
I am using presentViewController:imagePickerController to display the UIImagePickerController. For some reason when I end up dismissing that controller my original navigation controller looses it's stack and my application is back at the root view controller.
I am logging self.navigationController.viewControllers and I can see that after I run the presentViewController:imagePickerController line my navigation controller looses all of its controllers except for the root controller.
UIImagePickerController *imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.modalPresentationStyle = UIModalPresentationCurrentContext;
imagePickerController.sourceType = sourceType;
imagePickerController.delegate = self;
imagePickerController.navigationBarHidden = YES;
self.imagePickerController = imagePickerController;
DLog(#"self.navigationController:%#",self.navigationController.viewControllers);
[self.navigationController presentViewController:imagePickerController animated:YES completion:^{
DLog(#" after presenting self.navigationController:%#",self.navigationController.viewControllers);
}];
////Closing it
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
DLog(#"self.navigationController:%#",self.navigationController.viewControllers);
[self.navigationController dismissViewControllerAnimated:YES completion:^{
}];
}
/////Where my NC is set up
OFMainViewController *mainController = [[OFMainViewController alloc]init];
mainController.managedObjectContext = self.managedObjectContext;
navigationController = [[UINavigationController alloc]initWithRootViewController:mainController];
[self.window setRootViewController:navigationController];
Instead of using self.navigationController use self for both dismissing and calling the imagepickerviewcontroller.
You should present imagePickeController on self instead of self.navigationController.
[self presentViewController:imagePickerController animated:YES completion:^{
DLog(#" after presenting self:%#",self.navigationController.viewControllers);
}];
And dissmiss it accordingly:
////Closing it
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
DLog(#"self.navigationController:%#",self.navigationController.viewControllers);
[self dismissViewControllerAnimated:YES completion:^{
}];
}
The iOS simulator version 5.1 (272.21) closes every time I press a button to switch views.. any idea why?
- (IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] initWithNibName:nil bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
Thats the code for the buton on ViewController.m
By seeing your code, here is my idea,
If you are using XIB then use this way
- (IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[self presentViewController:second animated:YES completion:NULL];
}
and if you are not using any XIB use this way..
- (IBAction)SwitchView:(id)sender {
SecondView *second = [[SecondView alloc] init];
[self presentViewController:second animated:YES completion:NULL];
}
That might help
In presentModalViewController does not call any methods after login the Facebook using SSO.
SignInViewController *signView=[[SignInViewController alloc]init];
signView.delegate=self;
[self.navigationController presentModalViewController:signView animated:YES];
[signView release];
- (void)cancelAction
{
[self dismissModalViewControllerAnimated:YES];
}
The cancelAction method is calling but not dismissed..
Please help me.
SignInViewController *signView=[[SignInViewController alloc]init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:signView];
[signView release];
[self presentModalViewController:navigationController animated:YES];
[navigationController release];
-(void)cancelAction
{
[self dismissModalViewControllerAnimated:YES];
}
try implementing this...
hope this will work for you..
I am presenting a modalcontroller in a view, after i dissmiss the view i want to present another modalView but the code is not working, i have a delegate method that is being called when i press a button on the first modal vieview in witch i have the code.
inside the parentView the method for the firstview delegat:
-(void)newMessageModalView:(NewMessageModalView *)controller didFinishSelecting:(int)selectedChannel{
[self dismissModalViewControllerAnimated:YES];
SecondView * detailView = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[self presentModalViewController:SecondView animated:YES];
[detailView release];
[self dismissModalViewControllerAnimated:YES];
}
You are presenting SecondView, which is your class and not your instance. Even if that was right, you are dismissing it straight away.
Move [self dismissModalViewControllerAnimated:YES]; to detailView.m
-(void)newMessageModalView:(NewMessageModalView *)controller didFinishSelecting:(int)selectedChannel{
SecondView * detailView = [[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[self presentModalViewController:SecondView animated:YES];
[detailView release];
}
For example, in detailView.m
- (void)cancelBtnTouched:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
I have even tried implementing a delay right before the call to popToRootViewControllerAnimated however that does no good either. It just does not get called.
-(IBAction) btnSignOut{
[[self tabBarController]setSelectedIndex:0];
[[self navigationController]popToRootViewControllerAnimated:NO];//DOES NOT GET CALLED
Overview *overviewController = [[Overview alloc] initWithNibName:#"Overview" bundle:nil];
//Lets place OverView in navController
UINavigationController * navController = [[UINavigationController alloc] initWithRootViewController:overviewController];
// [[self navigationController] popToViewController:ComposeViewController animated:YES];
//Now lets display it
[self.tabBarController presentModalViewController:navController animated:YES];
[navController release];
[overviewController release];
}
It seems like the [self navigationController] does not contain any view to pop