Present a FormSheet QLPreVIewController within a UIVIewController? - ios

i want to open QLPreVIewController as a from sheet model style.
Here is my code
-(void)openPdfFile{
QLPreviewController *previewer = [[QLPreviewController alloc] init];
[previewer setModalPresentationStyle:UIModalPresentationFormSheet];
[previewer setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
// Set data source
[previewer setDataSource:self];
[previewer setDelegate:self];
// Which item to preview
[previewer setHidesBottomBarWhenPushed:TRUE];
[[[[UIApplication sharedApplication]keyWindow]rootViewController]presentModalViewController:previewer animated:TRUE];
}
but it always present with full screen
help please

From the docs:
You can push it into view using a UINavigationController object, or can present it modally, full screen
So, you could try presenting a navigation controller as a form sheet and pushing the preview controller as the root view controller.

Related

Navigation Controller presented modally is empty 2nd time

I am trying to present a UITableViewController modally on one of my view controllers which is further embedded in a UITabBarController. The code I am using is -
ContactTableViewController *contactsVC=[self.storyboard instantiateViewControllerWithIdentifier:#"contact"];
UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:contactsVC];
navController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
contactsVC.myDelegate = self;
[self.navigationController presentViewController:navController animated:YES completion:nil];
The view is presented just fine the first time I do it but when I navigate to this view again in my app, the view being presented is completely blank.. No navigation bar buttons, no title, nothing..
Can't figure out a reason... Any help is very much appreciated!
UPDATE:
HomeViewController *vc = [[HomeViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
This what I do to navigate to that view again while unhiding the tab bar. Home View is the view that presents the Contacts Table View modally.

Unable to call navigation controller from present view controller in ios

In my application i am launching one screen using present UIModalViewController and on that screen I have oneUIButton, if we click on that UIButton alert will come then select yes on alert view now we have to call another view usingpushviewcontroller. But screen is not coming if we use below code can any one help me.
[self.navigationController pushViewController:requestViewController animated:YES];
Try with one root navigation controller and then present your controller modally as follows :
FirstViewController *firstView=[[FirstViewController alloc]init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:firstView];
[self presentViewController:navigationController animated:YES completion:nil];
and then for push another view as follow :
SecondViewController *secondView=[[SecondViewController alloc]init];
[self.navigationController pushViewController:secondView animated:YES];
It will work first using present modal viewController and then using push navigation viewControllers on to the stack.

How to display something in a root view in ios using storyboard?

I am creating an application in ios using storyboard. I have a Tab Bar Controller as my root view, from this page I can navigate to other pages using the tabs, but how can I insert any text or image in the root view for the tab bar controller.
The default page (or root page as you are putting it) for a tab bar controller is one of the other UIViewControllers only. A UITabBarController can show another UIViewController inside it. There can be no text or image right inside a UITabBarController, but there can be a UIViewController inside it which has text or images. It is just a container for other view controllers.
Check out this example, it will help simplify things.
FirstViewController *fistView = [[FirstViewController alloc] initWithNibName:#"FirstViewController" bundle:nil];
SecondViewController *secondView = [[SecondViewController alloc] initWithNibName:#"SecondViewController" bundle:nil];
NSArray *viewControllersArray = [[NSArray alloc] initWithObjects:fistView, secondView, nil];
self.tabController = [[UITabBarController alloc] init];
[self.tabController setViewControllers:viewControllersArray animated:YES];
In the code above, the firstView controller will be displayed initially in the tabController, so what you want to do is add text and images and stuff inside firstView's xib file (or code).

Change displayed view in a UIPopoverView

So I'm presenting a UIPopoverView like so:
if (self.BStatePopoverViewController == nil) {
RedStatePopoverViewController *settings =
[[RedStatePopoverViewController alloc]
initWithNibName:#"RedState"
bundle:[NSBundle mainBundle]];
UIPopoverController *popover =
[[UIPopoverController alloc] initWithContentViewController:settings];
popover.delegate = self;
self.BStatePopoverViewController = popover;
}
[BStatePopoverViewController setPopoverContentSize:CGSizeMake(320, 445)];
[self.BStatePopoverViewController presentPopoverFromRect:[sender bounds] inView:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
Once the view is loaded in the popover, I have a button which I'd like to use to present a new UIViewController within the popover. I tried just presenting it as a modal view but this changes the parent view as opposed to the one in the popover:
PopupDischargeViewController * dischargeview = [[PopupDischargeViewController alloc] initWithNibName:#"PopupDischargeViewController" bundle:nil];
[self presentModalViewController:dischargeview animated:NO];
Any help as to how I do this would be much appreciated.
Thanks!
To change the view controller the popover should display once it's been initialized use UIPopoverController's method – setContentViewController:animated:
You could also add your RedStatePopoverViewController to a UINavigationController and use its methods – pushViewController:animated: and – popViewControllerAnimated: to navigate between view controllers
Hope this helps!

How to show quick look of a document in a splitview based iPad app

I have to show quick look of a document in the detailView of a splitview based app. In the master view I have a UITableView with the list of all the files in the Document folder of my app. I'm trying to use the QLPreviewController in the DetailViewController, in this way:
QLPreviewController *previewController = [[QLPreviewController alloc] init];
previewController.dataSource = self;
previewController.delegate = self;
previewController.currentPreviewItemIndex = ...;
[[self navigationController] pushViewController:previewController animated:YES];
[previewController release];
I'm able to see the preview of the document, but I don't longer see the toolbar at the top of the detail view, and in portrait mode I'm stuck forever, because I'm not able to see the file list in the master view. I also tried to make DetailViewController subclass of QLPreviewController, but without success.
I think instead of pushing the previewController into the [self navigationController], what I believe you need to do instead, from what you described, is to set the previewController as the detail view of your UISplitViewController.
This can be done like so
[splitViewController setViewControllers:[NSArray arrayWithObjects:masterViewController, previewController, nil]];
If you want to have the navigation bar for for the previewController to appear, you can wrap the previewController with a UINavigationController before setting it as the detail view in UISplitViewController like so:
UINavigationController *wrapperNavigationController = [[[UINavigationController alloc] initWithRootViewController:previewController] autorelease];
[splitViewController setViewControllers:[NSArray arrayWithObjects:masterViewController, wrapperNavigationController, nil]];
Cheers
Try
[self presentModalViewController:preview animated:YES];
instead of
[[self navigationController] pushViewController:previewController animated:YES];

Resources