To display mini view with controls for chromecasting video in app , root view need to be changed progrmatically. the below code need to be added to the storyboard.
// Wrap main view in the GCKUICastContainerViewController and display the mini controller.
UIStoryboard *appStoryboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
UINavigationController *navigationController =
[appStoryboard instantiateViewControllerWithIdentifier:#"MainNavigation"];
GCKUICastContainerViewController *castContainerVC =
[[GCKCastContext sharedInstance] createCastContainerControllerForViewController:navigationController];
castContainerVC.miniMediaControlsItemEnabled = YES;
self.window = [[UIWindow alloc] initWithFrame:UIScreen.mainScreen.bounds];
self.window.rootViewController = castContainerVC;
But i made tabbar controller app , rootview intiated from storyboard. can somebody help me to change or modify the rootview to get miniView (container view) in tabbar application?
Changing root view when using tab view does not look mandatory thing to me just try adding the complete navigationController object itself on the tab.
By this way on any one of the tab is will have your mini view with controls.
Related
Full disclaimer- I'm pretty new to iOS. I created a tableview with custom cells using the storyboard with a navigation controller as the initial entry point, and my tableview as the navigation controller's root view. When I run the app in the simulator, it seems as though everything is oversized/zoomed in, though my storyboard looks like this:
I've tried with iPad and iPhone and in both devices my story board doesn't pop up properly. I instantiate my root view controller thus:
- (BOOL)application:(UIApplication *)applicationdidFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
//get a pointer to my main storyboard
UIStoryboard *mainStoryBoard = [UIStoryboard storyboardWithName:#"Main" bundle:[NSBundle mainBundle]];
//instantiate my nav controller + item controller through the storyboard
UINavigationController *nav = [mainStoryBoard instantiateViewControllerWithIdentifier:#"navStoryBoard"];
ItemsViewController *ivs = [mainStoryBoard instantiateViewControllerWithIdentifier:#"tableStoryBoard"];
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
self.window.backgroundColor = [UIColor clearColor];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
// Override point for customization after application launch.
return YES;
}
Why won't my tableView appear in the correct size when I run my app? Am I instantiating my views incorrectly?
From the screenshot it looks like you are using Size classes (which is usually enabled by default). And hence the zoomed or scaled up behaviour.
If you are developing for a particular form factor, you may disable the "Use Size Class" property of the View Controller. More details here: https://developer.apple.com/library/ios/recipes/xcode_help-IB_adaptive_sizes/chapters/EnablingAdaptiveSizeDesign.html
However, if you want your UI to be scalable on different form factors - you should keep this checked and use Autolayout constrains for your Table View. More details here: https://developer.apple.com/library/ios/recipes/xcode_help-IB_auto_layout/chapters/UnderstandingAutolayout.html
I have four apps and want to combine them into one app.
If I added those projects into a project workspace -- for example there's project A and project B --
is it possible to click a button and go to project A's root controller,
then click another button go to project B's root controller ?
If it's possible, how can I do that?
is it possible to click a button and go to project A's root
controller, then click another button go to project B's root
controller?
A natural way to do that would be to manage the various "root" view controllers with a tab bar controller. For example, your app delegate could create a UITabBarController programmatically, and then load it with the root view controllers from each of your storyboards. It'd go something like this:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.tabBarController = [[UITabBarController alloc] init];
// Project 1
UIStoryboard *storyboard1 = [UIStoryboard storyboardWithName:#"Project1" bundle:nil];
UIViewController *controller1 = [storyboard1 instantiateInitialViewController];
// Project 2
UIStoryboard *storyboard2 = [UIStoryboard storyboardWithName:#"Project2" bundle:nil];
UIViewController *controller2 = [storyboard1 instantiateInitialViewController];
// Project 3
UIStoryboard *storyboard3 = [UIStoryboard storyboardWithName:#"Project3" bundle:nil];
UIViewController *controller3 = [storyboard1 instantiateInitialViewController];
// Project 4
UIStoryboard *storyboard4 = [UIStoryboard storyboardWithName:#"Project4" bundle:nil];
UIViewController *controller4 = [storyboard1 instantiateInitialViewController];
// Add the controllers to the tab controller
[self.tabBarController setViewControllers:#[controller1, controller2, controller3, controller4]
animated:NO];
//...put any other app initialization stuff here...
return YES;
}
At this point the tab bar will have four buttons, one for each "root" view controller, and you'll be able to switch between them at will.
I haven't compiled the above, but it should be enough to get you started. You will of course have to sort out any dependancies that the various view controllers might have on the app delegate, etc. But that shouldn't be too difficult. You should also make sure that each view controller is configured with a tab bar item, so that the tab bar controller will know what icon and name to use on the corresponding button.
I want to launch a childViewController of my initialView when it is launched from sliding or pressing a push notification.
Right now, I can launch to the childView, but the functions do not work. One of the labels I've initiated in the .m file is also not showing.
How can I make sure every function (back button(that pops back to parent), functionButtons in the view, segues it leads to) works properly.
This is my code for loading the view:
UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:#"MainStoryboard"
bundle: nil];
NotificationsViewController *viewController= [mainStoryboard instantiateViewControllerWithIdentifier:#"NotificationsViewController"];
UINavigationController *nav = [[UINavigationController alloc]
initWithRootViewController:viewController];
[_window setRootViewController:nav];
Problem:
The root view controller provides the content view of the window. Assigning a view controller to this property installs the view controller’s view as the content view of the window. If the window has an existing view hierarchy, the old views are removed before the new ones are installed that is why you cannot see the back button because they no longer exist.
Solution:
Pushes the view controller onto the receiver’s , the navigation bar will provide navigation back to the previous view controller.
NotificationsViewController *viewController = [[NotificationsViewController alloc] init];
[self.navigationController pushViewController:viewController animated:YES];
I've successfully implemented MFSideMenu so that all the navigation works properly except scrollsToTop in the scroll views (Specifically in my TableViewControllers and one ViewController where the UIscrollview takes up the whole frame). scrollsToTop is not working, even though it is enabled in each TableView.
I know that it's the MFSideMenu causing the issue because I removed it from the project and the scrollsToTop is working fine then.
So here's how I call the MFSideMenu from the AppDelegate on launch:
//Instantiate the Side Menu and the center view
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:[NSBundle mainBundle]];
UITabBarController *tabBarController = [storyboard instantiateViewControllerWithIdentifier:#"MainTabBar"];
SideMenuViewController *leftSideMenuController = [[SideMenuViewController alloc] init];
UINavigationController *leftViewNavigationController = [[UINavigationController alloc] initWithRootViewController:leftSideMenuController];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController:tabBarController
leftMenuViewController:leftViewNavigationController
rightMenuViewController:nil];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];
The TableViews I'm concerned with are embedded in NavigationControllers, which are embedded in the tabBarController referenced in the code above. And when I remove this block of code, the scrollsToTop works properly.
I think I need to adjust the container to include the TableViewControllers somehow. Any Ideas on how to do that?
The answer to my own question:
The problem appears to be that I had the left menu inside a navigation controller. So I abandoned that, and made a storyboard layout for the menu controller to use instead. And in that storyboard layout I added a navigation bar to cover up the black space that normally appears in this version of MFSideMenu.
So the new window setup in AppDelegate is...
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"MainStoryboard" bundle:[NSBundle mainBundle]];
UITabBarController *tbc = [storyboard instantiateViewControllerWithIdentifier:#"MainTabBar"];
//Then put get the left side menu controller, but inside of a navcontroller
SideMenuViewController *leftSideMenuController = [storyboard instantiateViewControllerWithIdentifier:#"SideMenu"];
MFSideMenuContainerViewController *container = [MFSideMenuContainerViewController
containerWithCenterViewController:tbc
leftMenuViewController:leftSideMenuController rightMenuViewController:nil];
self.window.rootViewController = container;
[self.window makeKeyAndVisible];
The scrollview problem in the other UIViewController turned out to be an Autolayout issue.
I'm implememting a design based on the TabbedBanner example in the iAdSuite. I have a UINavigationController in the first tab. In that UINavigationController I have a view controller that simply has a button that pushes to another view controller. The pushed view controller is set to Hide Bottom Bar On Push in Interface Builder.
Here is the code where I'm setting up the UITabBarController.
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:[[NSBundle mainBundle].infoDictionary objectForKey:#"UIMainStoryboardFile"] bundle:[NSBundle mainBundle]];
_tabBarController = [storyboard instantiateViewControllerWithIdentifier:#"TabBarController"];
_tabBarController.delegate = self;
FirstViewController *firstView = [storyboard instantiateViewControllerWithIdentifier:#"FirstViewController"];
UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:firstView];
_tabBarController.viewControllers = #[[[BannerViewController alloc] initWithContentViewController:firstNav], ];
self.window.rootViewController = _tabBarController;
[self.window makeKeyAndVisible];
return YES;
}
Everything works except the TabBar does not get hidden when I push to the next view controller. I have tried hiding the TabBar using the Interface Builder check box as well as using nextViewController.hidesBottomBarWhenPushed = YES and neither way works.
If I remove the BannerViewController implementation, the TabBar hides exactly as it should.
It seems to me that the BannerViewController is interfering with the UINavigationController being able to hide the TabBar.
Is it possible to use Hides Bottom Bar When Pushed to hide the TabBar in this type of setup?
Thanks
Note: I realize that the code above only has one tab. I removed the other tabs for clarity.
I think this is happening because the BannerViewController itself is just a container viewController and it never actually pushes another view controller. The view controllers are pushed within the container.