I have a TabBar on the screen and a View with some buttons on it. When a button is clicked, I create a ViewController (with a view from a nib) and add it to the keywindow of the application. I put this view offscreen and start an animation to make this new view slides from the bottom of the screen, and cover the tabBar. On this new view there is a UIPicker and 2 buttons (select / cancel). When one of this buttons is clicked, the PickerView slide off the screen and his controller is dealloc.
This works fine except for one thing : if I click on the zone where the tabBar is located and hidden by my new view, the tabBar get the click event !
How can I make the tabBar non responsive ? (Remember that I don't push the new view) Or maybe it isn't the right way to do this ?
EDIT & ANSWER : The problem came from the fact that I did a mistake in the height setting. I typed 160 instead of 260.
[myPickerController.view setFrame:CGRectMake(0, 480, 320, 260)];
The last 100 px, even if displayed, where "transparent" to event and get transfered to the TabBar who stands in that zone (even if it was hidden).
I am not sure but why don't you try
yourTabbar.userInteractionEnabled = NO;
when the view is visible. Make sure you set
yourTabbar.userInteractionEnabled = YES;
when view is dismissed.
You should use method named in your application:
tabbar1.hidesBottomBarWhenPushed = YES;
Related
I am trying to make some kind of popup view when a button i pressed on the iPhone. And it would be nice if I could manage that popup view with a ViewController. I have found out that the UIPopoverController could have been the solution, but it seems that it only works on the iPad...
But anyway, are there any similar solutions for the iPhone?
I am using storyboard
Check out these repos on Github:
https://github.com/werner77/WEPopover
https://github.com/50pixels/FPPopover
Create a separate view controller and resize its xib file and make it look like a popup.
Then ADD this view controller as a subview, and also add it as childController too.
[self addChildViewController:self.popOverViewController];
[self.view addSubview:self.popOverViewController.view];
Now Make it hidden initially.
self.popOverViewController.view.hidden = YES;
If a user taps on Button then using fade in & Fade out animation you can hide/unhide it.
I can tell you how to fade in and fade out if you want to know it further, I hope you can do it easily.
In interface builder make a UIView size of the screen and then make another in that Uiview with the style, size and the such for your pop over. Make its class, hook everything together.
CustomPopUpView *view = [[CustomPopUpView alloc] initWithFrame.....]
Add this all to your UIViewController with
[self.view addsubview:view]
Then attach a tapGestureRecognizer to the back view that animates the whole view off screen when tapped. So now if they click off your pop over view it close it will animates it off screen.
Hope this makes sense.
BooRanger
The application has a Tabbar Controller as its rootViewController. Now the requirement is on click of a button in the navigation bar, another view should come half way into the screen without any tab bar, and the other half should have the original view that has the tab bar in it. Is this possible to create?
Any help would be appreciated.
EDIT 1:
I did try
[UIApplication sharedApplication].keyWindow.rootViewController.view.frame = CGRectMake();
but the problem is, another view wont be seen in this, as the whole window frame is being shifted.
EDIT 2:
I have added a dummy pic of the requirement.
Create a custom view by subclassing UIView and show that in your current view controller in the first half.
You can use UIKit animation for animating the view if needed.
Finally found the solution to it.
On click of the button,
objThird.view.frame = CGRectMake(120, 0, 320, 480);
UIView *windowVIew = [self.tabBarController.view superview];
[windowVIew addSubview:objThird.view];
self.tabBarController.view.frame = CGRectMake(-200, 0, 320, 480);
objThird = Object of new view that i want when the button is pressed.
self.tabBarController.view superview = Gives you the window view. thus now you can add your view to the window.
And the rest is just playing with the frames of the views.
I have this UINavigationControl that has its toolbar visible and is showing the RootViewController. Then I push a new viewController into the screen but I like the toolbar to be invisible, while this other viewController is being shown.
Then, to show the viewController and hide the toolbar of the UINavigationControl I do this:
self.navigationController.toolbar.hidden = YES;
UIViewController *newVC = [[UIViewController alloc] init];
[self.navigationController pushViewController:newVC animated:YES];
The problem is that any touch on this new view controller in the are correspondent where the toolbar was visible on the last view controller is not detected.
As you know, the toolbar sits on a rectangle at the bottom of the screen, has the screen width and 44 pixels high (if I am not wrong). So, the new pushed view controller responds to touch on its full view are except those on this rectangle.
See the following picture. I have 3 buttons. Buttons 1 and 2 will respond to touches, but not button 3, because it is inside the area where the toolbar of the other view was...
And more than that, if I paint the background color of the new view with red, for example, the whole screen will be red, except for that bottom rectangle that will be white (and white is not the color of the previous view). I have checked and the view has 320 x 480...
any clues? thanks.
I think you are looking for hidesBottomBarWhenPushed property of a UIViewController.
See this related question here.
I have a navigation Controller as the view of a popover, so that there is a navigation bar at the top.
On the first view there is no prompt for the navigation bar, so it remains at it's usual small size.
I then push the next view controller which does need a prompt and the bar expands, except behind the view, hiding the Title and Back button.
If I comment out the code in loadView, so that self.view is never set, then you can see the backbutton and title, but you can't click on the back button, as if it was behind another view.
I never had this problem in 3.2, only now in 4.2
Here you can set the size of popover using the following code:
self.contentSizeForViewInPopover = CGSizeMake(320, 460);
You need to set the content size of popover in view using this code and you can add this code in the viewdidLoad mehtof of the controller. Let me know if you still have any question.
I have an application with a navigation bar and a tab bar. A user can navigate to a view which displays images in a scroll view. I'd like to have the same behavior as the iPhone photo app: Nav bar at the top, tool bar at the bottom, which will hide or show based upon a tap.
I'm moving my view to the window object in order to achieve full screen mode. This works fine:
myView = [self.view retain];
self.view = nil;
[window addSubview:myView];
But when I want to redisplay the Nav & tool bar, I run into a problem. The bars show fine, but the view is empty, and I can't seem to add any content to the view:
[myView removeFromSuperview];
self.view = myView;
I got a lot of good info from this post
but can't quite get the right combination.
By simply setting the controller's view, you aren't adding it as a subview to anything else, so it will never appear.
Moving views around like this can get a little tricky. I recommend that you not move the view from one to the other, but instead have two UIViews. Add second UIView to the window's subview and set it to hidden=YES initially. When you want to show it, set the image for the UIImageView, and then set the hidden property to NO.
what's wrong with just using setNavigationBarHidden: animated: and setToolbarHidden:animated:?