As below screenshot showed, I have a black dimmer View on the top and a viewController on the bottom(the white one) with half screen size.
What I want to do is when I tap on the dimmer place aka. outside of the viewController. This viewController should be dismissed.
YES, I found tons of topic using touchesBegan. But in my case it is not working, the problem is touchesBegan cannot detect touches outside current presented viewController. It would never be triggered when I click on that dimmer view.
And if I use Gesture check on the dimmer view, I could not dismiss this viewController from dimmer view too.
Any advice is welcomed if anyone met this similar situation with me.
You should be able to add a UITapGesture to the views window, look here: Dismiss modal view form sheet controller on outside tap
Related
I have a UIPickerView on a UIActionSheet. Right now the UIActionSheet makes the view behind the UIActionSheet not touchable. Is there a way that I can make it touchable? Or is that just how a UIActionSheet works?
I don't believe it is possible to make the view behind the UIActionSheet touchable without dismissing it first. They're meant to be modal, i.e. require the user's attention before being dismissed.
From UIActionSheet class reference (emphasis mine):
For applications running on iPhone and iPod touch devices, the action sheet typically slides up from the bottom of the window that owns the view. For applications running on iPad devices, the action sheet is typically displayed in a popover that is anchored to the starting view in an appropriate way. Taps outside of the popover automatically dismiss the action sheet, as do taps within any custom buttons. You can also dismiss it programmatically.
I suppose a way around this could be that you just create your own view that displays similarly. For example, create a UIView that you can animate the same (slide up) when a button is pressed. This UIView can contain your UIPickerView and whatever else you need (probably a cancel button to dismiss it).
Hope this helps, good luck!
Is there any way to keep a UITextField first responder even as I push another view controller?
Essentially, I'm taking a screenshot of the screen, using that screenshot in the new view controller, and then popping the second view controller. The issue, though, is that it isn't a smooth transition; when the view controller pops, the keyboard in the picture disappears (since the picture was in the second view controller but has since been popped), but the actual keyboard hasn't reappeared yet. You see the keyboard sliding up just after the picture disappears. Is there anyway to prevent this such that the keyboard is just always there?
I don't have any other UITextFields in the new view controller, only the screenshot, a UIButton, UIScrollView, and two UIGestureRecognizers.
Thanks in advance!
I'm confused on how storyboarding works.
So I created a simple app where the root view controller is a navigation controller.
I dragged a button to the the rootViewController of the NavigationController.
I dragged another view controller onto the screen, made it's background orange, and made it a subclass of OrangeViewController.
I dragged a connection from the status bar area of my rootViewController to the OrangeViewController.
I made this Segue Push and called it ShowOrange.
I created an action for my button that has:
- (IBAction)push:(id)sender {
[self performSegueWithIdentifier:#"ShowOrange" sender:self];
}
That's all it does. So when I press the button, it does show OrangeViewController. Then when I press back however, it keeps my background Orange. The title does change to ViewController, and there is no back button, but the background is orange. I was wondering why it does this?
My other question is a generic question with dragging segues. I seem to be able to drag it from the button itself, or the status bar. Is there a difference? What is really happening when that connection is made? Thanks.
Edit: Picture included
This particular answer is just for your second question:
Dragging from the button is analogous to setting that button's action to be performing the segue. Dragging from the view controller object (which is what I think is happening when you drag from the 'status bar', and would also happen if you dragged from the view controller while more zoomed out, or from the view controller in the list view), you are just setting it up to be used in code (in this case, it must have an identifier. The button segue does not need an identifier).
I am working on an app which has UITabBar at the bottom of app. One of the tab holds UITableviewController and another holds UIViewController. UITableViewController is customized to hold grid of images. When I tap on these images, my App pushes another view in navigationcontroller but at this time I remove tabbar and put toolbar. So far everything works fine. But when I go back to parent view I see white space at the bottom of it. I am hiding toolbar in viewWilldisapper so that I can not see on parent view.
Can anyone tell me where I am going wrong?
Regards,
Sumit.
You don't need to hide toolBar in viewWillDisappear. When you use the method hidesBottomBarWhenPushed to hide tabbar it will automatically hides and display when you push and pop. Try removing the piece of code where you are hiding toolBar in viewWillDisappear.
I have a UIViewController (A) that modally presents a second view controller (B). Then, that second view controller modally presents a UIImagePickerController (IP). Basically, I have a stack of 2 modal view controllers.
(A) --modally presents--> (B) --modally presents--> (IP)
View controller (A) is the delegate of the image picker, and it dismisses the entire modal stack using:
[self dismissModalViewControllerAnimated:YES];
The problem is with the animation. When dismissing a modal stack like this, the currently visible view should slide off the bottom of the screen, revealing the newly visible view. So in this case, I expect (IP) to slide off the bottom of the screen, revealing the view for (A).
However, what actually happens is this: The image picker view simply disappears, immediately revealing the view for (A), and only the navigation bar animates off the bottom of the screen. The status bar is also left as black translucent instead of transitioning back to a standard gray; this seems to indicate that the image picker normally does some kind of "cleaning up" that isn't being performed when it's dismissed as part of a modal stack.
If I replace the image picker with another generic view controller, the animation works fine. If (IP) is dismissed by (B), the animation also works fine. The problem seems to occur only when dismissing multiple modal view controllers containing UIImagePickerController.
Has anyone seen this before? Any ideas what I might be doing wrong or how to work around this?
Unfortunately, the method dismissModalViewControllerAnimated does not work exactly as you would expect (at least not visually). To achieve what you want, you need to dismiss both modal viewcontrollers in a row, the first non-animated and the second one animated, as described e.g. here.