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];
Related
Any idea why it's not possible to hide status bar when modal controller is presented as UIModalPresentationFormSheet on iPad?
override preferedStatusBarHidden doesn't work
You can hide the navigation bar throw the navigational controller.
For example use:
[infoViewNavController setNavigationBarHidden:YES animated:NO];
Where infoViewNavController is the Navigation Controller that will hold your viewController for Modal Presentation.
Assuming you are calling it like this:
UINavigationController *infoViewNavController =
[[UINavigationController alloc] initWithRootViewController:viewControllerToShow];
infoViewNavController.modalPresentationStyle = UIModalPresentationFormSheet;
infoViewNavController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[infoViewNavController setNavigationBarHidden:YES animated:NO];
self.navigationController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
self.navigationController .modalPresentationStyle = UIModalPresentationFormSheet;
[self.navigationController presentViewController:infoViewNavController animated:YES completion:nil];
I have 2 viewcontrollers in a TabBarController, in 2nd ViewController I have a button which on click should take me to ThanksViewController with out Tabs anymore!!
Please check my code below:
//AppDelegate.m
UINavigationController *nav=[[UINavigationController alloc]initWithRootViewController:_viewController];
self.window.rootViewController = nav;
//ViewController.m
tab=[[UITabBarController alloc]init];
tab.delegate=self;
oneViewController=[[OneViewController alloc]init];
UINavigationController *oneNav=[[UINavigationController alloc]initWithRootViewController:oneViewController];
oneNav.title=#"One";
twoViewController=[[TwoViewController alloc]init];
UINavigationController *twoNav=[[UINavigationController alloc]initWithRootViewController:twoViewController];
twoNav.title=#"Two";
views=[[NSMutableArray alloc]initWithObjects:oneNav, twoNav, nil];
tab.viewControllers=views;
[tab.view setFrame:CGRectMake(0, 0, 1024, 748)];
[self.view addSubview:tab.view];
In my TwoViewController (tab 2) I've a Button 'OK' which on click should take me to ThanksViewController, for that I've written the following code:
//TwoViewController.m
-(void)OK
{
ThanksViewController *thanksViewController=[[ThanksViewController alloc]init];
[self.navigationController pushViewController:thanksViewController animated:YES];
}
My problem is I want to exit from TabBarController and move on to the ThanksViewController(without TabBarController at the bottom) but in this case I'm getting the ThanksViewController in the TabBarController itself in place of the TwoViewController.
Can someone please suggest me in this case, thanks in advance.
After push ThanksViewController do you want to be possible to go back and present TabBarController again?
If so, use modal, like this:
ThanksViewController *view = [[ThanksViewController alloc] init];
UINavigationController *navThanks = [[UINavigationController alloc] initWithRootViewController:view];
[navThanks setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:navThanks animated:YES];
[self.view setHidden:YES];
I have a button in a viewcontroller that loads a motherViewController. This seems to be working correctly but for some reason the newly introduced view is so tall that the content at the bottom of are cropped.
- (IBAction)LoginButton:(UIButton *)sender
{
FirstViewController *FirstView = [self.storyboard instantiateViewControllerWithIdentifier:#"First"];
SecondViewController *SecondView = [self.storyboard instantiateViewControllerWithIdentifier:#"Second"];
ThirdViewController *ThirdView = [self.storyboard instantiateViewControllerWithIdentifier:#"Third"];
FourthViewController *FourthView = [self.storyboard instantiateViewControllerWithIdentifier:#"Fourth"];
FifthViewController *FifthView = [self.storyboard instantiateViewControllerWithIdentifier:#"Fifth"];
FirstView.Username = self.UsernameBox.text;
UINavigationController *FirstNavController = [[UINavigationController alloc]init];
[FirstNavController pushViewController:FirstView animated:NO];
UINavigationController *SecondNavController = [[UINavigationController alloc]init];
[SecondNavController pushViewController:SecondView animated:NO];
UINavigationController *ThirdNavController = [[UINavigationController alloc]init];
[ThirdNavController pushViewController:ThirdView animated:NO];
UINavigationController *FourthNavController = [[UINavigationController alloc]init];
[FourthNavController pushViewController:FourthView animated:NO];
UINavigationController *FifthNavController = [[UINavigationController alloc]init];
[FifthNavController pushViewController:FifthView animated:NO];
tabBar = [[UITabBarController alloc]init];
tabBar.viewControllers = [NSArray arrayWithObjects:FirstView, SecondView, ThirdView, FourthView, FifthView, nil];
[self.view addSubview:tabBar.view];
}
I don't whether i'm right or not. But here's the answer, you are trying to add UIViewController (UITabbarController) to your ViewController. So you need to position it in your view, for example
tabbar.view.frame = CGRectMake(0, 0, 320, 460);
But only thing i don't know its how it's perfectly positioned, when we are adding to window. Try your code by setting frame for your tabbarcontroller.
try this -
tabBar.tabBar.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin;
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.
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 ;