Container view is expected to be populated at this point - ios7

i have a simple ios implementation. There is a tableviewcontroller embedded in a navigationcontroller and a qlviewcontroller in this implementation, navigationcontroller is embedded in a tabbarcontroller too.
Actual tab lists a lot of image files, if a cell is selected in the tableviewcontroller, a qlpreviewcontroller will be instantiated and image file will be shown. another tab shows only settings of app.
i have subclassed the qlpreviewcontroller. The instance of this subclass will be created with the following code part;
XYQLPreviewController *qlpvc = [[XYQLPreviewController alloc] init];
qlpvc.hidesBottomBarWhenPushed = YES;
[self.navigationController pushViewController:qlpvc animated:YES];
i want to hide tabbar in the preview controller so that there is enough place to preview.
these all work very well with ios 6 and below but with ios 7 i have the following problems;
Back button of navigation bar in qlpreviewcontroller doesnt respond, its not clickable.
if i back navigate with this new cool slide transition of ios 7, ta ta my tabbar got lost, i see only a white layer at the tabbar not my cool tabbar.
i see the following log message in log screen,if i select an image file and instantiate the subclass of previewcontroller.
"Container view is expected to be populated at this point"
what a problem can it be , i have no idea.
Please help.
PS:i have only a xib file not the storyboard.

If you want to hide the tab bar, I would say your best bet is to present the preview controller as a modal instead of pushing it onto the stack. Then when the user closes it (instead of hits back), it will bring them back to the tab bar view.
[self.navigationController presentViewController:qlpvc animated:YES completion:nil];

Related

QLPreviewController delegate method doesn't get called in iOS 10, but does get called if ran earlier than iOS 10

Here is my code. This may sound like redundant question but my scenario is different as I am not adding QLPreviewController as a subview but present as a controller.
After downloading from dropbox, I present it like-
self.pdfViewController = [[QLPreviewController alloc] init];
self.pdfViewController.delegate = self;
self.pdfViewController.dataSource = self;
[self presentViewController:self.pdfViewController animated:YES completion:nil];
and I also have QLPreviewControllerDataSource, QLPreviewControllerDelegate listed as the protocol. Besides, it is working if being run in earlier than iOS 10.0.
Please help me.
It looks like iOS 10 has changed the way that QLPreviewController is presented. On iOS 9 when I preview an image by presenting the QLPreviewController modally I see a nice zoom effect and the initial state of the preview is with a black background and the navigation and toolbar hidden. I can tap the image to make the bars visible (which changes the background to white). Tapping again toggles the state.
On iOS 10 the same code results in the white background view appearing and the zoom animation being incorrect (it seems to appear from off the bottom of the screen).
I found that implementing this practically undocumented new data source method for iOS 10 fixed the issue:
- (UIView* _Nullable)previewController:(QLPreviewController *)controller
transitionViewForPreviewItem:(id <QLPreviewItem>)item
{
return [self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:MIDPhotoImageRowIndex_Image inSection:MIDPhotoSectionIndex_Image]];
}
The view I return is the same view that previewController:frameForPreviewItem:inSourceView: is using as the reference for the original content's frame (i.e. the image view in my table cell).
The documentation for this delegate method at the time of writing just says "No overview available".
Implementing that method did mean that the previewController:frameForPreviewItem:inSourceView: is now called on iOS 10. I just wish there was a way to default to the original black background without navigation bars.

Tab Bar controller disappearing when moving to another view (iOS SDK, Using storyboards)

I am building an iPhone app using storyboards and I have a problem with the tab bar controller. On one of the views that is linked from the tab bar controller (view1), there is a button that leads to another view (view2). On View2, there is a button that leads back to View1. Very straight forward. But when I go from view1 to view2, the tab bar disappears, and even worse, when I go back to View1, the tab bar is still gone...
How can I fix that? (I have yet to put ANY code in the app, there is only the storyboard and the apple provided AppDelegate Class (and also a main file I suppose, but I am not intending on touching that).
Any Reply is Highly appreciated!
If you do a modal segue from a view that is a tab bar view, it will get rid of the tab bar for the modal view you are presenting.
Secondly, when you segue you are creating a new instance of the view controller. So I am guessing you are segueing from view1 to view2 and losing the tab bar, then you are segueing back to view1. At this point you have created view1, view2, and a second copy of view1 that does not have a tab bar.
I would suggest one of two things.
1.) If you want to keep the tabs at the bottom when you segue from view1 to view2, then click on view1, at the top of the screen select Editor/Embed In/ Navigation Controller. This will embed your view1 in a navigation controller. Then if you change your segue from Modal to Push it will keep your tab bars at the bottom. The navigation bar at the top also make it easy to go back from view 2 to view 1 the correct way (by popping the view) rather than creating a new segue. If you do not like the navigation bar, then you can change the "Top Bar" property to "None" in the inspector. You will then need to create some other way in view2 to get back to view1. (BY POPPING THE CONTROLLER, NOT BY SEGUEING)
2) If you don't want to set up a navigation controller you will have a little bit harder time keeping the tab bar stuff at the bottom of the view2 controller. In fact, I'm not sure you can do it at all with a modal segue, you'd probably have to write some type of custom segue. Either way, If you want to transition back to view1 and get to the correct controller (not a new version without the tabs) then you need to attach an action to whatever button you are using to segue and use the following code (I also attached the code for navigation controller push segues, in case you create a navigation controller and get rid of the navigation bar.)
For Modal Segue:
[self dismissModalViewControllerAnimated:YES];
For Push segue:
[self.navigationController popViewControllerAnimated:YES];
Your best bet is to use the navigation controller method, as you are assured to keep your tabs. You can then either use the navigation bar to return (the easy way, no code needed) or you can get rid of it and use a button and the code above.
Good luck!
I had the same problem, i know this is an old question but [self dismissModalViewControllerAnimated:YES]; is deprecated in iOS 6.
What i used is:
[self dismissViewControllerAnimated:YES completion:nil];

UITabbarcontroller with nested pages - cannot get tab bar control to show root

I have used UITabbar control to navigate to the top level pages of my app. Each top level page navigates to 5 other pages using command buttons to drill deeper. When the user selects the next tabbar item, instead of navigating to the root, they end up on the page they were last reading in the hierarchy. I am using XCode 4 and Tab Bars have been created using IB.
How can I change this behavior so that the tab bar button always navigates to the top level page? Your help would be very much appreciated since I have spent many days trying to resolve this issue.
I believe this will work if your tabs have UINavigationController at their root
//somewhere in the initialization process
tabBarController.delegate = self
- (void)tabBarController:(UITabBarController *)tabBarController didSelectViewController:(UIViewController *)viewController{
UINavigationController *navController = (UINavigationController *)viewController;
if([navController.viewControllers count]>0)
[navController popToRootViewControllerAnimated:NO];
}
I have implemented UITabBar with each button loading a separate view controller and each of those view controllers having a navigation controller as a drill-down interface. When each button on the tab bar is clicked, the UIViewController is loaded and it is responsible for handling the drill down.
This sounds like what you want to do. Since I'm not sure what you mean by "page", I don't know how you are implementing the change that happens when a button is tapped on the tab bar. It sounds like you have one UIViewController and that's not quite how the UITabBar was designed to function. I could be wrong, so I think a little more explanation is needed.
If you are implementing with multiple UIViewControllers, You may want to think about whether a user is going to want to remain buried in the drill down even on changing tabs. Not sure what you App does, but this may be desired behavior.

Move UITabBar to the top of a UITabBarController?

I just finished designing a application that uses a top bar that toggles between three UIViewControllers. My first thought was to use a UITabBarController, since it works very simular.
However, the tabBar is at the bottom and in my PSD, it's at the top. Is there anyway I can change it? I see in the library I can drag in a UITabBar, but I don't know how to get it to change pages from there.
Please help!
Coulton
Hope the below code helps
UITabBarController *tabC = [[UITabBarController alloc]init];
tabC.tabBar.frame = CGRectMake(0, 0, 320, 70);
NSArray *arr = [[NSArray alloc]initWithObjects:firstObj,secObj, nil];
tabC.viewControllers = arr;
[self.window addSubview:tabC.view];
Worked fine for me
I think it can be done, but you should be aware of this:
"Important: In iPhone OS 3.0 and later, you should not attempt to use the methods and properties of this class to modify the tab bar when it is associated with a tab bar controller object. Modifying the tab bar in this way results in the throwing of an exception. Instead, any modifications to the tab bar or its items should occur through the tab bar controller interface. You may still directly modify a tab bar object that is not associated with a tab bar controller."
So, in your UI (I suppose you defined it in Interface Builder), instantiate a UITabBar object (by choosing it in the IB library and dragging it to your view in IB). Choose the default position and also define the way that this tab bar autoresizes (using the size pane of the info window). Then, add an outlet to your view controller of type UITabBar, and, finally, connect the tab bar object to the tab bar outlet.
Once you have done this, in your view controller's viewDidLoad method you can customize any property of the tab bar that you want to.

Can I use a UINavigationController as the detail view of a UISplitViewController?

I'm running into a problem with an iPad app where I would like to have UINavigationControllers in both of the views within a UISplitView. I've looked through other similar questions here, but most link to a tutorial online that doesn't completely solve the problem. Here's a 2-minute walkthrough to re-create the problem I'm having:
Create a New Project in XCode, starting from the Split View-based Application template.
Add the following NSLog statement as the first line within the DetailViewController's willHideViewController method:
NSLog(#"toolbar: %#", toolbar);
If you run the application now, the log will show that the DetailViewController's toolbar is alive and well. Now...
Open MainWindow.xib and expand the SplitViewController.
Drag a Navigation Controller from the library on top of the DetailViewController.
Expand the new Navigation Controller and change the class of the UIViewController within to a DetailViewController.
Ctrl-drag from the SplitViewController to the DetailViewController and assign it as the delegate.
Save MainWindow.xib and run the app again.
At this point, the detail view has a navigation bar and an empty toolbar. If you view the logs, you should find that the toolbar is null. Why is this? Am I missing some sort of connection in Interface Builder? Is the navigation bar the problem for some reason?
Unlike the tutorial at http://www.cimgf.com/2010/05/24/fixing-the-uisplitviewcontroller-template/, I would like to keep both the navigation bar and the toolbar (preferably with the toolbar at the top when in portrait and not visible when in landscape), so that I still have a functional "Back" button when the iPad is in portrait orientation.
Does anyone have any suggestions for fixing this problem? An example project with this sort of set-up would be ideal.
You can certainly use a navigation controller on the detail view of a split view controller. In fact, the iPad Settings app uses this approach. Probably the best way to get this setup is to create a new project in Xcode 4.x and select the "Master-Detail Application" template. It will generate a split view controller with 2 navigation controllers, one for the left view and one for the right view.
To your toolbar question, to keep things simple I would put a toolbar in the bottom. You can still put bar button items on the top navigation bar, although you can only put them in the left, middle, or right. If you need lots of items on the top bar, one way is to add a toolbar to the detail view and hide the navigation bar in the viewWillAppear event of the detail view class.
Here is an example on how to hide the navigation bar and show the toolbar:
- (void) viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
self.navigationController.toolbarHidden = NO;
self.navigationController.navigationBarHidden = YES;
}
I've found the built-in UISplitViewController to behave badly when trying to combine it with most of the other built-in view controller subclasses. Matt Gemmell's MGSplitViewController is a lot more flexible and has worked pretty well for me, despite the odd glitches (though those are at least fixable as the source code is provided).