A side view with SWRevealViewController - objective-c

In my main view controller,I m trying to create a side view menu,and after reading every possible tutorial,I could not find any solution to this .
I have 2 other view controllers that related to storyboard view.
I am trying to load them as a side views , but i see the main navigator,button, and a black screen behind .
Here is the code i use from their example, in my main view that is loaded first .
UIViewController *side=[[sideView alloc] init];
UIViewController *front=[[frontView alloc] init];
UINavigationController *frontNavigationController = [[UINavigationController alloc] initWithRootViewController:front];
UINavigationController *rearNavigationController = [[UINavigationController alloc] initWithRootViewController:side];
SWRevealViewController *mainRevealController = [[SWRevealViewController alloc]
initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];
mainRevealController.delegate = self;
self.viewController = mainRevealController;
[self.view addSubview: self.viewController.view];

Related

Set view controller as the first controller in UITabBarController

I have this code in my appDelegate.m that implements a UINavigationController with a UITabBarController:
FristViewController *primeiro = [[FristViewController alloc] init];
UINavigationController *nav1 = [[UINavigationController alloc] init];
[nav1 pushViewController:primeiro animated:YES];
FilesViewController *segundo = [[FilesViewController alloc] init];
UINavigationController *nav2 = [[UINavigationController alloc] init];
[nav2 pushViewController:segundo animated:YES];
InfoViewController *terceiro = [[InfoViewController alloc] init];
UINavigationController *nav3 = [[UINavigationController alloc] init];
[nav3 pushViewController:terceiro animated:YES];
UITabBarController *tabbar = [[UITabBarController alloc] init];
tabbar.viewControllers = [NSArray arrayWithObjects:nav2, nav1, nav3, nil];
nav1.tabBarItem.image = [UIImage imageNamed:#"tab1.png"];
nav2.tabBarItem.image = [UIImage imageNamed:#"tab2.png"];
nav3.tabBarItem.image = [UIImage imageNamed:#"tab3.png"];
self.window.rootViewController = tab bar;
It's all right with this code, in my case when I beginning my app appearing on the first controller is FilesViewController because it is the first in the order of Tab Bar, but in my case I would like the first controller was the FristViewController without changing the order of items in the tab bar, how can I do this?
Go to your storyboard or xib where you created your TabBar. Drag the First controller to 1st position. Or programmatically you could set tabBar.selectedIndex = 0;

Navigation controller and no storyboards

I am writing an app in Objective C. For this project I cannot use ARC or storyboards. It should have 6 views. Firstly, the navigation controller shall keep table view (it will contain some data passed in from an array). In the toolbar on the top once the item has been pressed the app should move to second view.
I know that I need to code that in my delegate file, but I a not quite sure what needs to be included. Those were the requirements.
In fact when I run my app it does not show that navigation controller which got table view as my entry view. In the settings I cannot find a checkbox in order to select it and make it an entry view.
Any suggestions?
Best regards
Best way to use UITabBarController
Firsts Create all object of UIViewController and UINavigationController in AppDelegate.h file and use following method of AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window=[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds ]];
self.viewCon=[[ViewController alloc] init];
self.navCon=[[UINavigationController alloc] initWithRootViewController:self.viewCon];
self.navCon.navigationBar.tintColor=[UIColor blackColor];
self.viewCon.title=#"First View";
self.fView=[[FirstViewController alloc] init];
self.FnavCon=[[UINavigationController alloc] initWithRootViewController:self.fView];
self.FnavCon.navigationBar.tintColor=[UIColor blackColor];
self.fView.title=#"Secound View";
self.sView=[[SecoundViewController alloc] init];
self.SnavCon=[[UINavigationController alloc] initWithRootViewController:self.sView];
self.SnavCon.navigationBar.tintColor=[UIColor blackColor];
self.sView.title=#"Third View";
.
.
// create UIViewController and UINavigationController As you need
.
.
.
UIImage *img1=[UIImage imageNamed:#"Australia.gif"];
self.tbItem1=[[UITabBarItem alloc] initWithTitle:#"First Page" image:img1 tag:1];
self.viewCon.tabBarItem=self.tbItem1;
UIImage *img2=[UIImage imageNamed:#"Cameroon.gif"];
self.tbItem2=[[UITabBarItem alloc] initWithTitle:#"Secound Page" image:img2 tag:2];
self.fView.tabBarItem=self.tbItem2;
UIImage *img3=[UIImage imageNamed:#"Canada.png"];
self.tbItem3=[[UITabBarItem alloc] initWithTitle:#"Third Page" image:img3 tag:3];
self.sView.tabBarItem=self.tbItem3;
NSMutableArray *viewArr=[[NSMutableArray alloc] init];
[viewArr addObject:self.navCon];
[viewArr addObject:self.FnavCon];
[viewArr addObject:self.SnavCon];
self.tbCon=[[UITabBarController alloc] init];
self.tbCon.viewControllers=viewArr;
[self.window addSubview:tbCon.view];
[self.window makeKeyAndVisible];
return YES;
}

Navigation bar doesn't appear in uiviewtable in popupovercontrol

I have PopupoverControl and this popup has UIViewtablecontrol and one of UITable control should navigate to another UIViewtablecontrol but it doesn't navigate this is the code in selection in first uitableview:
OpenFileViewController *openfileview = [[OpenFileViewController alloc] initWithNibName:#"OpenFileViewController" bundle:nil v_files:[self GetFiles] v_ui:parentview];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:openfileview];
[self.navigationController presentModalViewController:navController animated:YES];
in .xib file in both uiviewtable I enabled Top Bar with Navigation Bar but it doesn't appear why?
No need for the new navController, try this instead:
[self.navigationController pushViewController:openfileview animated:YES];
Edit:
The root view controller of the popover should be a UINavigationController object, so try this when you're creating the popover:
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController: optionw];
UIPopoverController *optioandiaglog= [[UIPopoverController alloc] initWithContentViewController:navController];

its not navigating to the class

I am writing the following code in a button click event and i am trying to navigato the class PDFReaderViewController, but on click of the button its not navigating, can anybody tell me y
UINavigationController *addNavigationController;
PDFReaderViewController *avController = [[PDFReaderViewController alloc] initWithNibName:nil bundle:nil];
if(addNavigationController == nil)
{
addNavigationController = [[UINavigationController alloc] initWithRootViewController:avController];
addNavigationController.navigationBar.tintColor = [UIColor blackColor];
addNavigationController.navigationBar.alpha=0.7f;
addNavigationController.navigationBar.translucent=YES;
[self.navigationController presentModalViewController:addNavigationController animated:YES];
}
What you are actually looking for?
In your code you are trying to present a navigationController from another navigation controller.
To present a vieController as a modelViewController you don't need a custom NavigationController.You can present it simply by:
PDFReaderViewController *avController = [[PDFReaderViewController alloc] initWithNibName:nil bundle:nil];
[self.navigationController presentModalViewController:avController animated:YES];
[avController release];
Class *obj=[Class alloc];
[self.view addSubview:obj.view];
You can use this for navigating Class.

Buttons on top of UIPopoverController

I want to add two Buttons on top of UIPopoverController like it is shown in following screenshots:
HTML Edit
Thanks for helping me!
Add your view controller to a UINavigationController, then add the Navigation Controller to the UIPopoverController. Then in your UIViewController's viewDidLoad method, put this code in:
UIBarButtonItem *okButton = [[UIBarButtonItem alloc] initWithTitle:#"Ok" style:UIBarButtonItemStyleBordered target:self action:#selector(okayButtonPressed)];
UIBarButtonItem *cancelButton = [[UIBarButtonItem alloc] initWithTitle:#"Cancel" style:UIBarButtonItemStyleBordered target:self action:#selector(cancelButtonPressed)];
self.navigationItem.title = #"My Title";
[self.navigationItem setLeftBarButtonItem:cancelButton animated:NO];
[self.navigationItem setRightBarButtonItem:okButton animated:NO];
[cancelButton release];
[okButton release];
You need to initialize your popover with a UINavigationController directly. Then set the root view to your custom view controller.
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:yourViewController];
UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:navigationController];
Use a UINavigationController as the pop-over. Then, access the .navigationBar property of the navigation controller, get the .topItem, and set its .leftBarButtonItem and .rightBarButtonItem.
I wouldnt use a navigationcontroller like the previous posters suggested, apple recommends not using navigationcontrollers on ipad (with good reason) it doesnt behave as youd expect when pushing VC into the stack when used in popovers, now you dont really want to use the "navigation" aspect of it, but i wouldnt use navigationcontroller just because uw ant the bar....Use a UIToolBar instead, and set its buttons to whatever you want...no need to use a navigation controller here...
When I do this my navBar doesn't seem to fit properly inside of the UIPopoverController, as shown in the below:
http://www.flickr.com/photos/coleorton/4752223066/
Here's what I'm doing:
// alloc the Direct Reports view controller.
ToolsViewController *toolsViewController = [[[ToolsViewController alloc] init] autorelease];
UINavigationController *toolsNavController = [[[UINavigationController alloc] initWithRootViewController:toolsViewController] autorelease];
toolsNavController.title = #"Tools";
toolsNavController.view.frame = CGRectMake(0.0, -10.0, 320.0, POPOVER_HEIGHT);
if(![self.toolsPopoverController isPopoverVisible]){
// show popover
self.toolsPopoverController = [[[UIPopoverController alloc] initWithContentViewController:toolsNavController] autorelease];
self.toolsPopoverController.delegate = self;
self.toolsPopoverController.popoverContentSize = CGSizeMake(320.0, POPOVER_HEIGHT);
[self.toolsPopoverController presentPopoverFromBarButtonItem:sender
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
} else {
// close popover
[self.toolsPopoverController dismissPopoverAnimated:YES];
}
This worked!
//Determine how to present this view based on device
if ([UIDevice currentDevice ].userInterfaceIdiom == UIUserInterfaceIdiomPad) {
BNRAssetTypeViewController *contentViewController = [[BNRAssetTypeViewController alloc] init];
UINavigationController *popOverNavigation = [[UINavigationController alloc] initWithRootViewController:contentViewController];
self.assetPickerPopover = [[UIPopoverController alloc] initWithContentViewController:popOverNavigation];
[self.assetPickerPopover presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
then in the init function of contentViewController add this
//add a barbutton item which will help in adding new type
UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(addNew:)];
//set bar item to right side of navbarite
self.navigationItem.rightBarButtonItem =bbi ;