Keep UITextField as first responder when pushing new view controller - iphone

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!

Related

View is blank after modalViewController is dismissed

I am using PPRevealSideViewController and I am showing a ViewController modally after user taps a cell in a side view. When I dismiss a modal view controller, the view, where user tapped, is shown blank. Only after I move a little bit side view, it is shown again (refreshed). What might be the problem?
This was a side effect of your preload call on viewWillAppear or DidAppear in fact. The view should not be preloaded if shown. I added this behavior as default into the controller.
But the idea behind was to test if [self.revealSideController sideDirectionOpened] != PPRevealSideDirection from the side you are trying to preload.
Fixed right here https://github.com/ipup/PPRevealSideViewController/commit/a1ca242422f0a8b4666df5987ca4a020f869bb99

Storyboard, where to drag connection from one view controller to the next

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).

gestures and input stops after popviewcontrolleranimated or poptorootviewcontrolleranimated

I have a main uinavigationcontroller that loads a uitableview as a subview as my "main view", I push a new uiview controller on, then in that viewcontroller I add a left nav button to popviewcontroller, bringing me back to the main view
all of that works just fine, the issue is when I pop back to the main view all input is doa, no swipes, scrolls, gestures, whatever, can't click on any of the table cells or scroll the table
not getting thrown to the debugger so I can only assume I haven't crashed the app, and I can do programmatic things in viewdidappear on the main view that affects the view, set timers, etc, but my screen input just doesn't work
any ideas as to where my input goes?
It's hard without any code, but you're probably adding gesture recognizers to views in the view you just popped. You can try adding the gestures to UINavigationController's view, or window.view, or some other view that stays alive between navigation stack pushing/popping.

How to get the animation right: inputView from a UINavigationController's nav bar?

I have a custom UIControl subclass with a UIPickerView as inputView. When the control is tapped, it calls becomeFirstResponder and the picker view automatically slides up from the bottom of the screen, like the system keyboard. This is working great!
The problem is that I am using the custom control as the titleView of a UINavigationItem. It functions properly, but if the view controller is popped off the navigation controller stack while the picker view is visible, the animation is wonky.
What I want to happen:
everything is pushed off screen to the right at the same time
What actually happens:
first, the background view and navigation bar slide off screen, the picker remains in place
then, after they are gone, the picker slides off to the right also
When I use the custom control inside the view controller's main view, it animates away just like the standard keyboard. So it seems as though this is a function of "coming from" the navigation bar, which is animated separately from the views inside.
How can I fix this, so that the inputView slides out with the rest of the content?
Turns out this can be fixed by calling endEditing: on the UINavigationController's view. In other words, within a view controller:
[self.navigationController.view endEditing:YES];
This causes the input view to slide down while the rest of the view slides off to the right. Not exactly the same as the system keyboard, but not obviously weird.

Bad animation when dismissing modal UIImagePickerController

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.