In my view controller, I have:
- (void)viewDidAppear:(BOOL)animated
{
LoginViewController* lvc = [[LoginViewController alloc] init];
lvc.delegate = self;
[self presentModalViewController:lvc animated:NO];
[lvc release];
}
However, this doesn't show up. What might be the possibilities? I tried to do a NSLog inside and it prints out.
Here's how I wire it up:
This is a UISplitView application where I put this code inside a RootViewController
Did you link the View to the LoginViewController in IB? That's the most common issue...
If logging your navigationController does not give you nil, then try the following:
[self.navigationController presentModalViewController:lvc animated:NO];
You are probably creating your LoginViewController correctly. Try replacing:
LoginViewController* lvc = [[LoginViewController alloc] init];
with
LoginViewController* lvc = [[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil];
You need to specify which NIB to load the view controller from.
It turns out that I have a conflicting code in my UIDetailView, which is trying to do another popup...
Related
I have a UIViewController, I want to navigate from this view to my second view controller
SecondView *secondView=[[SecondView alloc] initWithNibName:#"SecondView" bundle:nil];
[self.navigationController pushViewController:secondView animated:YES];
[secondView release];
It doesn't work. It doesn't do anything and there is no error. What I'm missing?
SOLUTION
In Appdelegate file I've added a navigationcontroller.
UINavigationController *navCtrlr = [[UINavigationController alloc]initWithRootViewController:self.viewController];
[self.window setRootViewController:navCtrlr];
navCtrlr.delegate = self;
navCtrlr.navigationBarHidden = YES;
Is your view controller already inside a navigation controller otherwise it wont work. put an NSLog on self.navigationcontroller and see what it is printing
I have an alternative flow in my app. This flow starts in my firstViewController, then in this view a call my secondViewController like this:
- (IBAction)PressButton:(id)sender {
SecondViewController *second = [[SecondViewController alloc] init];
second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
UINavigationController *nav = self.navigationController;
[nav presentViewController:second animated:YES completion:nil];
}
In my secondViewController I want to push my thirdViewController. But it is not working I tried this ways:
- (IBAction)pressButton:(id)sender {
ThirdViewController *tvc = [[ThirdViewController alloc] init];
UINavigationController *nav = self.navigationController;
[nav pushViewController:tvc animated:YES];
}
When I press the button of secondViewController nothing happens.
What I'm doing wrong ?
I'm using:
OSX 10.8.2
Xcode 4.6
iOS 6.1
You must present the navigation controller modally, and have the second view as the root of that navigation controller. As well as calling presentViewController from the owning view not its parent navigation controller.
- (IBAction)PressButton:(id)sender {
SecondViewController *second = [[SecondViewController alloc] init];
second.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:second];
[self presentViewController:navigationController animated:YES completion:nil];
}
Instead of presenting just the second view controller, make sure to present an additional navigation controller.
SecondViewController *secondViewController = [[SecondViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:secondViewController];
[[self navigationController] presentViewController:navigationController animated:YES completion:nil];
If you are using storyboard just click on the source view xib, Ctrl+drag to destination (Create Segue), select modal from popup menu.Click on the newly created connection. Add a name for it then in source view controller [self performSegueWithIdentifier:#"Segue Name" sender:self];
If you are trying to get a button to direct you to a different page modally, you can go into the storyboard or xib file. Control click from that button to the view controller you want to go to. and then the popup menu will give you the options of what type of outlet you want to use. Hope this helps
I have got a problem here which I am trying to solve for last three days. When I run my iphone app it displays this screen
Everything works fine i.e. If I click "Log in With Email" button it does work.
When I click "Login with Facebook" it displays this screen
but once I click "logout" button it displays this screen
without title and "Log in with Email" doesn't work.
What can the problem?
Code behind logout button:
LoginViewController *LoginviewController = [[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil];
[self presentViewController:LoginviewController animated:YES completion:nil];
Logout button resides in UITabbarController(created programmatically). This is the screen shot of ViewController to which I am unable to transition for the second time
What did you assign VC for UITabBarController ? I bet UIViewController? Try assign UINavigationController instead of UIViewController
UINavigationController *navController = [[UINavigationController alloc] init];
SomeViewController *viewController = [[SomeViewController alloc] initWithNibName:#"SomeViewController" bundle:nil];
navController.viewControllers = [NSArray arrayWithObject:viewController];
UITabBarController *tabBarController = [[UITabBarController alloc] init];
[tabBarController setViewControllers:[NSArray arrayWithObjects:
viewController, nil]];
Then on SomeViewController.m
[self.navigationController pushViewController:anotherViewController animated:YES];
in anotherViewController.m
[self.navigationController popViewControllerAnimated:YES];
Hope that helps
may be check your code for anywhere does you disabled the User Interaction for Log in with Email button while presenting your LoginviaFacebook controller.
Use this code for presenting viewController in login with email btn:
LoginViewController *loginViewController = [[LoginViewController alloc] initWithNibName:#"LoginViewController" bundle:nil];
[self presentModalViewController:loginViewController animated:NO];
And for go back to your login page put this code in logout btn:
[self dismissModalViewControllerAnimated:NO];
So guys I solved the issue. Following code should have been placed in Logout button
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:appDelegate.LoginviewController];
[self presentViewController:navigationController animated:YES completion: nil];
I am trying to navigate from one page to another on a button click in a facebook appliaction.
I am using
registerUser=[[RegisterPage alloc]initWithNibName:#"RegisterPage" bundle:nil];
[self presentModalViewController :registerUser animated:YES];
for presenting the next view after getting response from facebook.
But it is not showing the next view. It works fine in all other places where I used to present other views.
Anyone have idea about this issue?
What exactly is 'self' here? Is it a viewcontroller? Or just a UIView?
I think this'll only work if self is a viewcontroller or some subclass of it.
My code to present a view controller is somewhat like yours (without a nib):
ViewController *controller = [[ViewController alloc] initWithNibName:nil bundle:nil];
[controller setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:controller animated:YES];
[controller release];
And to present a navigation controller it's like this (without a nib):
ViewController *controller = [[ViewController alloc] initWithNibName:nil bundle:nil];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
[navController setModalTransitionStyle:UIModalTransitionStyleCoverVertical];
[self presentModalViewController:navController animated:YES];
[navController release];
[controller release];
Sometimes simply copying someones code helps.
thanks for everyones reply.i have solved it after a long fight.i just dismissed the view before pesenting the next view and set dismissmodalviewcontrollerAnimated to NO.[self dismissModalViewControllerAnimated:NO];
nextview = [[LoginPage alloc]initWithNibName:#"LoginPage" bundle:nil];
[self presentModalViewController: nextview animated:YES];hope this help someone like me
I'm having difficulty in switching between xibs :(
first i was using navigationController and it worked well but i want to do it without using navigationController.
I tried presentModalViewController but it crashes my application. :((
Here is the code :
myViewController *viewController = [myViewController alloc] initWithNibName:nil bundle:nil];
myViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: myViewController animated:YES];
[myViewController release];
It is not working, ERROR received :
GDB:Program received signal : "EXC_BAD_ACCESS"
myViewController *viewController = [myViewController alloc] initWithNibName:nil bundle:nil];
viewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: viewController animated:YES];
this should work. your problem was that you declared a view controller and named it "viewController", but you were not using that. you were using the view controllers name, not the declared instance.
You have set your nibName to nil
Enter the name of your Xib file you want to display there
Like
myViewController *viewController = [[myViewController alloc] initWithNibName:#"nameOfYourXIB" bundle:nil]autorelease];
myViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentModalViewController: myViewController animated:YES];
remove the release statement from ur code and everything will work fine.
Actually u r releasing the viewcontroller before it is shown as the superview.
//[myViewController release];
Hope this helps u...
Don't release he controller its a global variable i suppose so just make it in nil in dealloc