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];
Related
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 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 am having problem in navigation of views.
I have VC say, Login, which I am calling from another VC like :
- (IBAction) btnAction
{ Login * login = [[Login alloc] init];
[self.navigationController pushViewController:login animated:YES];
}
in login VC there are two buttons say, Register and Forget Password, that calls another VC, RegisterVC and ForgetPassVC accordingly.
- (IBAction) btnRegisterNow : (id) sender
{
aRegister = [[Register alloc] initWithNibName:#"Register" bundle:nil];
[self.navigationController pushViewController:aRegister animated:YES];
}
- (IBAction) btnForgotPassword : (id) sender
{
forgotPassword = [[ForgotPasswd alloc] initWithNibName:#"ForgotPasswd" bundle:nil];
[self.navigationController pushViewController:forgotPassword animated:YES];
}
My Problem :
When I call Login by [self.navigationController pushViewController:login animated:YES]; every thing works fine.
But in some VCs I need to display login page as [self presentModalViewController:login animated:YES]; At this time the two buttons, Register and Forget Password does not work. On button click nothing happens.
What is the problem ? I think bocz of I have added Login as modal view not a pushViewConterller ??? if so then how can I accomplish this task ?
hope question is clear.
Thanks...
When you present your controller modally, they aren't in a navigation controller. You should write
UINavigationViewController *nvc = [[UINavigationViewController alloc] initWithRootViewController:login];
[login release];
[self presentModalViewController:nvc animated:YES];
[nvc release];
I think you should push the Forgot password & Register VCs also as modal controllers. Have you tried that?
When you are doing
[self presentModalViewController:login animated:YES]; in this case your view controller get passed and now when you try to implement [self.navigationController pushViewController:forgotPassword animated:YES]; it did ont work because you dont have navigation controller.
Is it necessary to present your login as modal view.
Then use this code:-
- (IBAction) btnAction
{
Login *login=[[[Login alloc]initWithNibName:#"Login" bundle:nil]autorelease];
UINavigationController *navController = [[[UINavigationController alloc] initWithRootViewController:login]autorelease];
[[self navigationController] presentModalViewController:navController animated:YES];
}
Now your forgot and register btn action will called and will navigate to the that corresponding page.
Present navigation controller with your login view controller as root controller.Check below code.
UINavigationController *navController = [UINavigationController alloc] initWithRootController:loginController];
[self presentModalViewController:navController];
[navController release];
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...
I have a view A where I have a code to push it to view B using:
[navController pushViewController:SecondViewController animated:YES];
when I get there and press back, the button says firstViewcontroller.
But when I press the buttons again to push it to the secondview again.
instead of showing 'firstviewcontroller' the buttons says secondviewcontroller.
and for some reason, my navigation-stack is adding and adding the secondview.
Can someone tell me what I do wrong?
I can't find any problem in my code.
Edit:
I have changed my code to:
FirstViewController *aFirstViewController = [[FirstViewController alloc] initWithNibName:#"FirstView" bundle:[NSBundle mainBundle]];
[navController pushViewController:aFirstViewController animated:YES];
[aFirstViewController release];
and it is still not working:S
I think u had not released the object of your SecondView.....
Anyways Put this at the place where u r giving your navigation code
SecondViewController *viewController = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
[self.navigationController pushViewController:viewController animated:YES];
[SecondViewController release];