I am working on iOS application and i have used the split view like structure which Facebook application has.
I have used the code which has the CLViewController, This code i have found from google.
All working fine but in my current application when the app loads the first screen itself shows the split view in which 80% screen shows the menu and 20% shows the detail page. I want to change it in a way the Facebook app works. In Facebook on loading app directly shows the news feed. so same way i want to load detail page first.
If anyone have any idea how can i achieve it please share.
Thanks in advance.
Code : How to use SWRevealViewController
Here first initialize your View controllers
FirstViewController * first = [[FirstViewController alloc]init];
SecondViewController * second = [[SecondViewController alloc]init];
Create BarButton....
UIBarButtonItem *revealButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"reveal-icon"] style:UIBarButtonItemStylePlain target:_revealVC action:#selector(revealToggleAnimated:)];
Put firstViewController and secondViewController into Navigation
First hide self.navigationbar
self.navigationController.navigationBarHidden = YES;
UINavigationController * navigationController1 = [[UINavigationController alloc] initWithRootViewController:first];
navigationController.navigationBar.topItem.leftBarButtonItem = revealButton
UINavigationController * navigationController2 = [[UINavigationController alloc] initWithRootViewController:second];
navigationController.navigationBar.topItem.leftBarButtonItem = revealButton
Initialize SWRevealViewController
_revealVC= [[SWRevealViewController alloc]initWithRearViewController:navigationController1 frontViewController:navigationController2];
_revealVC.rightViewController =nil;
_revealVC.rearViewRevealWidth = 60;
_revealVC.rearViewRevealOverdraw = 0;
_revealVC.bounceBackOnOverdraw = YES;
_revealVC.stableDragOnOverdraw = YES;
_revealVC.rightViewRevealWidth = 350;
_revealVC.rightViewRevealOverdraw = 0;
[_revealVC setFrontViewPosition:FrontViewPositionRight];
[_revealVC revealToggleAnimated:YES];
[self.navigationController setViewControllers:[NSArray arrayWithObject:_revealVC] animated:true];
Hope it will help you
Here you will get Split View you are looking for Click Here
Related
I am using am SWRevealViewController in my iOS 8.2 app. It works perfectly fine, but when my view displays though it a frosted navigation bar hangs around at the top of the screen, under the status bar. It is covering my background image, and I haven't found an easy way to remove it.
mainView = [[ViewController alloc] init];
sideMenu = [[MenuController alloc] init];
UINavigationController * frontViewController = [[UINavigationController alloc] initWithRootViewController:mainView];
UINavigationController * rearViewController = [[UINavigationController alloc] initWithRootViewController:sideMenu];
revealController = [[SWRevealViewController alloc] initWithRearViewController:rearViewController frontViewController:frontViewController];
revealController.delegate = mainView;
I searched through the SWRevealViewController code and didn't find anything obviously related to it. I tried commenting out suspicious sections of code and viewing the result. I hid the status bar. Nothing touched it.
I have tried a few things...
[frontViewController.navigationController setNavigationBarHidden:YES];
frontViewController.navigationController.navigationBar.frame = CGRectZero;
[frontViewController.navigationController.navigationBar setHidden:YES];
[revealController.navigationController setNavigationBarHidden:YES];
revealController.navigationController.navigationBar.frame = CGRectZero;
[revealController.navigationController.navigationBar setHidden:YES];
[revealController.navigationController.navigationBar setBounds:CGRectZero];
...to no effect.
As your front view is mainView you will be using
[mainView.navigationController setNavigationBarHidden:YES];
I hope this helps.
Upon completion of this question, I tried one final test.
[mainView.navigationController setNavigationBarHidden:YES];
This worked. It would appear that something in the process of embedding the mainView in the SWRevealViewController caused the navigation bar in the mainView itself to become visible, even though by default it was not.
I have recently removed the tab bar from my app in favor of a "slide out" styled menu which I have written myself. It appears to be working perfectly, except that the one split-view controller I use in the app does not work correctly on the iPad in portrait orientation (landscape is just fine). The problem I'm seeing is the detail VC ONLY is loaded into the portrait view, where both VCs load correctly in landscape view. This is on iOS7.
So, here is the code I'm using. This code has been moved from the AppDelegate (previously) to the root VC. There were some changes but relatively minor. It did work fine with the tab bar, but using this new slide out menu (i.e., a table view) I have this one problem. I'm only including the portions of the code that I think would be relevant.
AdminMasterViewController *adminMasterVC = [[AdminMasterViewController alloc] init];
UINavigationController *adminMasterNav = [[UINavigationController alloc] init];
adminMasterNav.viewControllers = [NSArray arrayWithObjects:adminMasterVC, nil];
adminMasterNav.view.frame = CGRectMake(0,0,[Utility screenWidth],[Utility screenHeight]);
AdminDetailViewController *adminDetailVC = [[AdminDetailViewController alloc] init];
UINavigationController *adminDetailNav = [[UINavigationController alloc] init];
adminDetailNav.viewControllers = [NSArray arrayWithObjects:adminDetailVC, nil];
adminDetailNav.view.frame = CGRectMake(0,0,[Utility screenWidth],[Utility screenHeight]);
UISplitViewController *adminSplitVC = [[UISplitViewController alloc] init];
adminSplitVC.viewControllers = [NSArray arrayWithObjects: adminMasterNav, adminDetailNav, nil];
adminSplitVC.delegate = self;
adminSplitVC.title = #"Admin";
adminSplitVC.view.frame = CGRectMake(0,0,[Utility screenWidth],[Utility screenHeight]);
vcArray = [NSArray arrayWithObjects:homeVC, adminSplitVC, expressiveNav, receptiveNav, typerNav, nil];
(The last line builds the array of all the VCs in the project; the code which creates these VCs has been omitted).
After the VC has been selected it is presented as a child VC as follows:
UIViewController *vc;
if ([selected isEqualToString:#"Home"])
{
vc = [vcArray objectAtIndex:VCHome];
}
else if ([selected isEqualToString:#"Administrator"])
{
vc = [vcArray objectAtIndex:VCAdmin];
}
... (others listed here)
[self.view addSubview:vc.view];
[self addChildViewController:vc];
[vc didMoveToParentViewController:self];
From what I have read there may be some issue with NOT using the tab bar, but the articles are confusing because a lot of them are dated. I will appreciate any input or suggestions on this problem as I've read everything I can find and don't really know where to go from here. TIA.
After a couple of days of reading and trying different things, an hours after posting the question I solved this. Just in case anyone else hits this same problem, here's the solution:
I subclassed the UISplitViewController and made it its own delegate.
Then, this delegate method solved it:
- (BOOL)splitViewController:(UISplitViewController *)svc shouldHideViewController:(UIViewController *)vc inOrientation:(UIInterfaceOrientation)orientation
{
return NO;
}
I'm opening a View from the navigationController, using the NVSlideMenuController. However, I haven't been able to show a Navigation Bar (which I definitely need).
I'm not familiar with NavigationControllers and after following a few tutorials, it still isn't clear enough to me how it works.
This is in the AppDelegate application didFinishLaunching:
IntroViewController* introVC = [[IntroViewController alloc] initWithNibName:#"IntroViewController" bundle:nil];
UIViewController *menuViewController = [[MenuViewController alloc] initWithStyle:UITableViewStyleGrouped]; // Your menu view controller
UIViewController *contentViewController = (UIViewController*)introVC; // The initial content view controller
menuViewController.navigationController.navigationBarHidden = false;
NVSlideMenuController *slideMenuController = [[NVSlideMenuController alloc] initWithMenuViewController:menuViewController andContentViewController:contentViewController];
self.window.rootViewController = slideMenuController;
return YES;
I tried adding the code to put the navbarhidden to false and it doesn't seem to work. Is there something else I missed?
Any help is very appreciated!
MyViewController *myViewController = [[MyViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:myViewController];
self.window.rootViewController = navigationController;
This will set the UINavigationController as your root view controller. If you MUST use NVSlideMenuController (which I have 0 experience with but really don't think it is necessary), then you can do the first two lines I gave you, and set the navigationController as the root for the NCSlideMenuController.
I would recommend Apple's documentation for UINavigationController, it is an extremely useful thing to know:
https://developer.apple.com/LIBRARY/IOS/documentation/UIKit/Reference/UINavigationController_Class/Reference/Reference.html
Having one main navigation controller in whole application and also one main tabbarcontroller , problem is that when i click om 'more' tab of tabbarcontroller at that time it's showing two navigation bars
to solve this problem i tried to hide my main navigation controllers navigationbar using following code :
self.tabbar.navigationController.navigationBarHidden =YES;
but doing this gives me unexpected result in the form of half navigationbar with half black background.
if any one knows the solution then please help me.
thanks in advance.
make viewController With separate UINavigationController,
put this code in Appdelegate
ViewController *a = [[ViewController alloc] initWithNibName:#"a" bundle:nil];
ViewController *b= [[CreateMeetingViewController alloc] initWithNibName:#"b" bundle:nil];
ViewController *c = [[SettingsViewController alloc] initWithNibName:#"c" bundle:nil];
UINavigationController *nav_1 = [[UINavigationController alloc] initWithRootViewController:a];
UINavigationController *nav_2 = [[UINavigationController alloc] initWithRootViewController:b];
UINavigationController *nav_3 = [[UINavigationController alloc] initWithRootViewController:c];
MainTabBar = [[UITabBarController alloc] init];
MainTabBar.delegate = self;
[MainTabBar setViewControllers:[NSArray arrayWithObjects:nav_1,nav_2,nav_3,nil]];
MainTabBar.view.frame=self.view.frame;
[self.view addSubview:MainTabBar.view];
You can check your .Xib you check the option Top Bar this should be 'None' in the identity inspector.
Write in viewWillAppear, i hope it will be helpful for you
[self.navigationController setNavigationBarHidden:YES animated:YES];
I have a UITabBarController that is working good.
Now before I open the tabController, I want to check if the user is registered, if not I want to open a registration page (RegistrationController) and then go back to my tabView.
How can I do this, since the TabBarController can only be the first page.
Thank you
u can have a viewController(VC1) pushing another viewController (VC2) and in viewDidLoad of VC2 u can add ur tabbar programmatically.
tabBarController = [[UITabBarController alloc] init];
tabBarController.view.backgroundColor = [UIColor clearColor];
VC3 *object1 = [[VC3 alloc] initWithNibName:#"VC3" bundle:nil];
VC4 *object2 = [[VC4 alloc] initWithNibName:#"VC4" bundle:nil];
tabBarController.viewControllers = [NSArray arrayWithObjects:object1, object2, nil];
tabBarController.delegate = self;
[[tabBarController.viewControllers objectAtIndex:0] setTitle:#"title"];
[[tabBarController.viewControllers objectAtIndex:1] setTitle:#"title"];
[self.view addSubview:tabBarController.view];
[object1 release];
[object2 release];
also u can do this
in the viewDidLoad of the tabBarController (default view), u can check a variable, if its 0 (i.e. user is not registered), then u can presentModalViewController with a registration form.
hope it helps. happy coding :)
You can add an overlay, over the table view controller (another view which will make the table view not visible, since it will be behind the view you're adding). On succcessfull login / registration, you remove the overlay view.