how to cover parent view fully from a subview in ios? - ios7

Im creating an ios app using story board. I want to add a subview over the current viewcontroller. the current view controller should be fully covered from that sub view. But my problem is when I add the subview it appear under the navigation bar. I set is as
[self.view addSubview:mysubview];
How do I fully cover my view from that sub view

Since you want to cover the complete navigation controller, you can try this instead:
[self.navigationController.view addSubview:mysubview];

Related

Need clarity on if I'm switching View Controllers correctly

I'm making an ipad app which has 11 view controllers in storyboard, one of which is a master view that contains buttons to control which of the other view controllers is displayed as its subview.
Does anybody know for sure if it's ok to use UIViewControllers as subviews of other UIViewControllers, with hard evidence from apple or another source? It has been working flawlessly for me using this method so far:
int nextPage = (method to determine nextPage based on button pressed);
[currentView.view removeFromSuperview];
currentView = [self.storyboard instantiateViewControllerWithIdentifier:[NSString stringWithFormat:#"page%i",nextPage]];
[self.view insertSubview:currentView.view atIndex:0];
[currentView.view setFrame:CGRectMake(0, 0, 1024, 768)];
Some people online say that if you are using ios5 or later, it's ok, but others say "NO NEVER DO THIS!!!" even if it's ios5. Others say to use container views, but in every tutorial I've seen to use a container view you just end up inserting the view controller as a subview to the main view anyway using this after you've inserted the child view:
[self.view addSubview:self.currentView];
I am not using a Navigation Controller because they have limited customizability and I do not want any stock tab bars or navigation bars, just all custom buttons.
Thanks in advance!
Yes of course, it's how UINavigationController works and how UITabBarController works. Interface Builder will event set it up for you with a container view.
see Creating Custom Container View Controllers
The takeaway is it's important to handle childViewControllers. This can get a bit tricky, but is important for notifications to propagate correctly.

Adding a view to a NavigationController that isn't pushed to the stack

I've added a UIToolbar to a NavigationController because I wanted to use the realtime blurring capabilities of the toolbar. I also wanted to customize the size - which means I can't use the toolbar built in to the NavigationController. I had to create my own and add it as a subview.
The problem is that I only want it on one particular view in my navigation stack. When I push subsequent views, the toolbar stays on the screen. I want it to be covered by the view pushed on the stack as the view slide-animates itself in to place.
How can I get it to do that without writing a custom animation?
[self presentViewController:MyController animated:YES completion:nil];
Presents a view like a modal. Exactly what I needed.

Always visible UIView

I want to place a UIView that will inform the user what is the status of the app. I want that view to be visible even if the user switches views, same thing as the UINavigationBar is always visible, but I don't want to use that bar, I would like to add another view that will show a message.
How can this be done? I can't add the view to the current view, because it will disappear, if the user changes views.
It should be added to the window? But how? I would then have to resize the views so that my new view can fit, but how?
Thanks.
Create a container view controller and set it as the rootViewController of the apps window.
Inside this container you have your status view, and you also resize the windows real rootViewController to take up the remaining space as a subview. If you are using a standard container view conrtoller (tab, navigation etc) as the root then you can use standard navigation methods and the status view will always be visible
There would be problems if you wanted to present modal views though, since these would go over the top of the status view
In your appDelegate.m add your view as subView of window.
UIView *mainBg = [[UIView alloc] init];
mainBg.frame = newframe;
[self.window addSubview:mainBg];
If you have a UINavigationController you can add your view to its view.
[self.navigationController.view addSubView:yourView];
Presenting modal views would cover the view, as stated in the other answer.

How can I hide the navigation bar when pushing a view controller?

I'm making customized UIScrollView such like pinterest's two column view.
The scrollview should have search function. So I tried to use UISearchDisplayController but I can't because UISearchDisplayController implements only UITableView.
So, I created search display controller such like UISearchDisplayController. It's good. well done.
But I have a big problem. I can't implement completely behavior of UISearchDisplayController when go to detail view.
See below images.
this image is UISearchDisplayController's behavior on Simulator's Contact App.
Detail view have a navigationBar when pushed. but first view's navigationBar is hidden.
The UISearchDisplayController's behavior is good to transition view. Search view don't have UINavigationBar and detail view has UINavigationBar separately. but my controller can't do that.
I call setNavigationBarHidden:animated method try to hide navigation bar when touch UISearchBar on search view.
How to implement second image. any ideas?
sorry for my bad english :)
The search bar is different view, so here you need to call the below methods while view is navigating from one view to others.
self.navController.navigationBarHidden = YES;
or
[self.navigationController setNavigationBarHidden:YES animated:animated];

UIPageViewController subview disappear while page change

I'm writing an UIPageViewController based application over which view I placed a subview:
[self.view addSubview:fontViewController.view];
This view fade in and out when I tap on the center of the main view (the pageviewcontroller one). When this view is shown, I don't want that disappears when I change the page. I think that this subview should be added to a layer over the main view and not to the view itself. Am I wrong? If not, how can I do that?
What is the parent of the main view?
In some cases this might work:
[self.view.superview addSubview:fontViewController.view];