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
Related
How would one create a now-playing like bar that can be swiped up from the bottom and swiped away from the top, that would always overlap some views but not all views - something like a z-index stacking with swipeable gestures on views?
It should work with something like JASidePanels
On iOs :-)
Screenshot of functionality here:
You should be able to do this by adding a subview to your UIViewcontroller (or JASidePanels, as it may be) and bringing it to the front. Something like:
BottomBarView *bottomBar = [[BottomBarView alloc] init];
[self addSubview:bottomBar];
[self bringSubviewToFront:bottomBar];
Note that this would be from your UIViewController, and not from AppDelegate.
Another option is to add the subview using a XIB or Storyboard and use Interface Builder to make sure that the view is at the right z-index.
To make it swipeable, you just have to listen for the right gestures, and to hide it, use bringSubviewToFront on some other view.
I have a UIViewCOntroller, and in that i have a button and a text field. When i click the button i display a UIToolBar.
Now when i click anything in the background (the textfield or the blank view) i need this UIToolBar to disappear. How can i do this programmatically ?
I know how to add a UIToolBar but all what i need to know is to hide it when the user clicks on the background.
I don't think i will have to paste any code here or show my workings so far, coz i have no clue how to get this done
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[self.navigationController setToolbarHidden:YES animated:YES];
}
May be it can help you....
You will need to capture a touch on the views outside of your toolbar to achieve this. If you have a custom UIView base class that all of your other views use, you might start there. Otherwise, perhaps use some sort of toggle to show/hide your toolbar instead in your UIViewController.
The easiest way to do this is to make a single large clear button that is behind the first button but above everything else. Normally have it set to hidden but when you show the toolbar unhide the button as well. When the button is clicked have it hide the toolbar and its self. No need to do anything crazy like sub classes.
I'm now working with view-based application. It's just simple. If I touch the view, the view flips using animation ability of UIView. This is all.
What I want to do after this...is...locating a kind of button in the middle of the main view. BUT!, the button must not be animated while the main view is flipping.
How do I do this?
I dont know this is a correct way or not and i havnt tried this. Just a thought.
Create a UIButton in appdelegate and add that button as subview to the UIWindow.
So you can access that button in anyview and so that you can keep that button in the front and change view controllers.
How can I make a custom view in iOS which appears above the existing view,but smaller? It should be like UIAlertView, but taken from a .xib file. After user taps a certain button, the small view vanishes and the normal view appears.
If this is posiible, how can I do it? And.. if it's not hard for you, please, include code.
Thanks in advance!
I think what you're looking for is a modal view. Modal views make it easy to have a view take over the screen for a little while, then when they get dismissed have the background view resume where it left off without having to worry about who's on top or handling events in partially-obscured views.
Here is Apple's article describing it.
They key is to have the controller class for your view call [self presentModalViewController:popupController animated:YES]; where "popupController" is the view controller for the view you want to show up. When you're ready to make it go away, call [self dismissModalViewControllerAnimated: YES];
You can just use the addSubview: method on your UIWindow or your visible UIViewController's view to show the UIView, and you can hide/remove it later by calling removeFromSuperview on the presented UIView.
I've been working pretty extensively the last couple months with UIImagePickerController, particularly with the new capabilities in OS3.1 and newer to overlay views on-top of the camera view. This has worked just fine.
However, I am currently working on a project where I'd like to be able to display the camera view of the UIImagePickerController within an existing view. Essentially, the exact opposite of what I've currently been doing.
An example would be a View Controller with navigation components (Think top and bottom horizontal bars with gradients), and upon tapping a button on one of these bars, then content area displays the camera view. The shutter animation would should up, and the top and bottom navigation bars would remain always on-top.
I've had success adding the UIImagePickerController to the window view, as well as presenting it modally, but haven't had any luck adding it as a subView.
ex:
[window addSubview:camera.view];
[self presentModalViewController:camera animated:YES];
All you need to do is call viewWillAppear and viewDidAppear.
Here is an example where _pickerController is an instance of UIImagePickerController:
[self.view addSubview:_pickerController.view];
[_pickerController viewWillAppear:YES];
[_pickerController viewDidAppear:YES];
Call viewWillAppear:YES on the image picker controller after adding its view to your view. Skip the modal view controller business.
I don't think the API provides direct access to the actual view of the UIImagePickerController. The class is actually a subclass of UINavigationController so I don't think it has an actual view itself but rather manages the calling of its subcontrollers and their views.
When you call the UIImagePickerController modally, its doesn't add the views it controls as subviews to the window (or any other view). That is what a modal view means. It presents the view off to the "side" of the view hierarchy.
Even if you could hack this together, I think Apple would reject it as not being part of the API and for violating the HIG.