In my project I have existing side menu i.e swrevealviewcontrtoller to display right side menu.It is working correctly. I want to add second right menu in between the project using slideNavigationController. This is the screen shot of my storyboard. I can not touch existing base code and Before login page I want to add slideNavigationController to display another right sidemenubar.
i.e not my root view controller for that I referred these two links.SlideNavigationController,Solution for making rootviewcontroller
StoryBoard Image
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle: nil];
LoginViewController *loginView = (LoginViewController*)[mainStoryboard instantiateViewControllerWithIdentifier: #"Login"];
[loginView setModalPresentationStyle:UIModalTransitionStyleCrossDissolve];
SlideNavigationController * slideNavCtl = [[SlideNavigationController alloc] initWithRootViewController:loginView];
[self.window setRootViewController:slideNavCtl];
It is taking LoginViewController as root view controller.
As we are using SwrevealViewController at the first it contains modal segue so I am not able to display the right menu in login view controller. After adding that code in app delegate I am able to display right menu in loginpage but login page is the rootview but I want splash screen as a rootViewController. Using SlideNavigationController I want to display another right menu in login .
Related
In my iOS Project, there is a login ViewController that sends the user to a TabViewController if he has the right credentials.
This TabViewController has 5 tabs, the fifth one is for Logout, which send the user back to the Login ViewController, and of course clears out the already filled credentials of the user.
My problem is that i have the menu of the TableView shown in my Login page.
How to i get rid of this menu in my Login ViewController page ?
I use Xcode6 & Objective-C
if you need any further explanations/source code of my problem, feel free to ask.
note:
In the beginning, I mean when the Login ViewController is first shown to the user, the menu doesn't show.
It turns out that whole UI architecture of your app is based on the UITabBarController. However it is not very good practice in your case. I would like to suggest you add separate modal controller for presenting login page.
Try:
self.tabBar.hidden = YES;
Assuming that you are using a storybaord I have the given solution
I created a sample application and tried replicating your issue, so here's the look at my storyboard
The way i designed it i have a separate login view controller and two view controller (Menu List and Logout) which are embedded in a tabbar controller.
If you're new to storyboard then embedding viewControllers with tabbarController is pretty much straight forward, you select the view controller first and then go to the editors menu in Xcode
Alright now coming back to business, code which i added on the IBAction of the login screen button is given below where MainTabbar is the storyboardID of the TabMaster controller
AppDelegate *appdel = [UIApplication sharedApplication].delegate;
UIStoryboard *storyBoard = appdel.window.rootViewController.storyboard;
TabMasterController *tabController = [storyBoard instantiateViewControllerWithIdentifier:
#"MainTabbar"];
[appdel.window setRootViewController:tabController];
When i executed the application everything was OK and I was able to see the tabbar items after I hit the action button on login screen
Now its time to write some code for the logout tabbar item, so I selected the view controller assigned to the Main tabbar controller and added the delegate mentod of UITabbarController which looks some what like this
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController
{
// Since i have two tabbar items 1 generally means logout in my case
if (tabBarController.selectedIndex ==1) {
AppDelegate *appdel = [UIApplication sharedApplication].delegate;
UIStoryboard *storyBoard = appdel.window.rootViewController.storyboard;
ViewController *tabController = [storyBoard instantiateViewControllerWithIdentifier:
#"LoginVC"];
[appdel.window setRootViewController:tabController];
}
}
LoginVC is the storyboardID of the Login View controller
After adding the above code when i used to tap on the logout tabbar item I was able to go back to the login screen in my storyboard.
Hope that helps.
Either you can add tab bar item programmatically or you can add in storyboard
If programmatically then add like
self.tabBarController.viewControllers = [NSArray arrayWithObjects:
[[UINavigationController alloc] initWithRootViewController:self.myContactsController],
[[UINavigationController alloc] initWithRootViewController:self.searchController],
[[UINavigationController alloc] initWithRootViewController:self.registrationController],
[[UINavigationController alloc] initWithRootViewController:self.loginController], nil];
Set tabbarController as initial view controller in storyboard
After checking login credential, On success
// to get list of current tab bar items
NSMutableArray *tbViewControllers = [NSMutableArray arrayWithArray:[self.tabBarController viewControllers]];
// to remove tab bar items using index value
[tbViewControllers removeObjectAtIndex:3];
[tbViewControllers removeObjectAtIndex:2];
// to add tab bar items
[tbViewControllers addObject:[[UINavigationController alloc] initWithRootViewController:self.myProfileController]];
[tbViewControllers addObject:[[UINavigationController alloc] initWithRootViewController:self.logoutController]];
// to set pre selected tab bar item
self.tabBarController.selectedIndex=2;
// set array items in tab bar
[self.tabBarController setViewControllers:tbViewControllers];
Fixed it, it's not the optimal solution but it worked for me:
what I did is :
1- I deleted the Tab Bar Item from my Login ViewController
2- I inserted a logout button in my table view screens
3- I added segues from my Table view screens to the login screen in my storyboard.
This way if the user clicks on the logout button , he will be directed to the login screen & cannot go back where he was unless he enters his credentials.
I am handling push on alert to jump/open a view in story board like this from delegate
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:#"Main_iphone4" bundle:nil];
ChatViewController *scvc = (ChatViewController *)[storyboard instantiateViewControllerWithIdentifier:#"ChatViewController"];
[self.window.rootViewController presentViewController:scvc animated:YES completion:nil];//not working show nothing while it works to jump using simple xib views.
and if i use
self.window.rootViewController =scvc;//it works but i need to get back on back button which causes it to get back in blank screen.
How to jump to a view controller using storyboard on handling push from delegate.
NOTE: The jump view have a back button,which need to dismiss the view too.
NOTE APP IS NOT NAVIGATION BASED
User opens the app and the LoginViewController is shown, once they enter their details and press the login button a NSURLRequest is made and if the result is success the app needs to load the HomeViewController.
Everything is working except for loading the HomeViewController.
I have tried instantiating HomeViewController and:
[self presentViewController:Home animated:YES completion:NULL]
But it doesn't load the new controller, I'm not sure if I need to segue or perform some other type of modal request I'm not aware of.
I assume Home is the class of the HomeViewController?
It would be more of cocoa style when its name was HomeViewController.
self.homeViewController = [[Home alloc]init];
By doing so you would have to care for creating and layouting all the views that the controller contols. If you do that with Interface Builder then use
self.homeViewController = [[Home alloc] initWithXib:#"NameOfTheNibFileHere"]];
If your view controller is layouted in a storyboard, then give it an ID "HomeID" in this example) within the storyboard and load it via.
self.homeViewController = [storyboard instantiateViewControllerWithIdentifier:#"HomeID"];
If it is the root view controller of your storyboard, then I suggest to use
UIStoryboard *sb = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
and go from there.
You can do this with a segue, but you don't want to trigger the segue from your login button - you need to do it programmatically. In Image Builder, go to the bottom of your login view and control-click on the yellow View Controller icon in the black bar and drag to your HomeViewController. Select "Replace" as the segue type and then give the segue an identifier (say "HomeSegue") as per usual.
Now, once your login has completed you can trigger the segue using
[self performSegueWithIdentifier:#"HomeSegue" sender:self];
If the login fails then you can stay on the login view controller and display an error as appropriate
I am developing a basic which has a story board like this:
When the UIButton is pressed the URL is loaded. If the URL request is succesfull then I have the "Success" view (on on the right) opened.
It all works fine but I can't seem to get the navigation controller to appear on the Success view.
Could someone help me? Also, if the navigation can go on that view, how would I add a "back" button to take the user back to the main view?
Here is my code so far:
UIStoryboard * mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
NSLog(#"%#", status_code);
UIViewController *linkSuccess = [mainStoryboard instantiateViewControllerWithIdentifier:#"linkSuccess"];
[self presentViewController:linkSuccess
animated:YES
completion:NULL];
Peter
Control drag from the my app controller (the little yellow icon on the lower left in your screenshot) to the Success view controller and it should bring up the box asking you what kind of segue. Because this is a navigation controller you want a push segue. Click on the new arrow going from the my app controller to the success controller in the storyboard that represents your new segue and in the properties inspector give it a name, perhaps something like showSuccess
Then in your URL request successful code use this:
[self performSegueWithIdentifier:#"showSuccess" sender:self];
Alternatively, if you want to instantiate it yourself (as you have in the code above) you need to add it to the navigation controller. For example:
UIStoryboard * mainStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
NSLog(#"%#", status_code);
UIViewController *linkSuccess = [mainStoryboard instantiateViewControllerWithIdentifier:#"linkSuccess"];
[self.navigationController pushViewController:linkSuccess animated:YES];
You have to extending success view controller from 'My App' controller. Click on 'My App'view controller header, hold ctrl + click on trackpad + move it to success view controller.
Should be work
I have a problem with my app organization.
I want an home view with four buttons. Each one pushing the view to a splitView.
So in my home view, I do not want any masterView displayed, ether in portrait or landscape mode.
But in my four next views, I want the masterView displayed at any time and I want to be able to have a back button to return to the home view.
My question is how do I achieve such a thing ?
Do I have to create my home View as the rootViewController of the app and then create one splitView per button. Then create a back button to dismiss the splitView.
Do I have to create one single splitView and play around with the master view display. I can't figure out how to hide my master class in portrait mode on certain views and show it on other views.
A UISplitViewController has to be the root view controller.
So you would start your app with a homeViewController that contains four buttons, each of which would tell your app delegate to remove the home view controller from root and create a splitViewController and make that the root.
Obviously to go back you would need a button on your splitViewController that would tell the app delegate to remove the splitViewController and replace with the newly loaded homeViewController.
an example of getting a viewController from a storyboard and attaching it to the window
window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:nil];
UIViewController *homeViewController = [mainStoryboard instantiateViewControllerWithIdentifier:#"HomeViewController"];
[window addSubview:homeViewController.view];
[window makeKeyAndVisible];