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.
Related
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 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
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.
On the iPhone, we can simply use (void) viewDidAppear:(BOOL)animated; to perform actions when a view becomes the focus. In some events, we have a modal view with another modal view on top of it and, on the iPhone, closing the topmost modal view will fire the viewDidAppear for the lower modal view.
This is not the case for the iPad, as the view stays "visible" even though it's behind another modal view. Is there any way to tell from within a UIViewController when the view itself becomes the active view?
Can't you just use when the modal view controller's view disappears?
When the modal view's controller recieves the viewWill/DidDissapear you know that the original view is visible again.
EDIT:
in the viewDidDissapear of the modal viewcontroller add this:
[self.parentViewController viewDidAppear:animated];
This will make the viewDidAppear method be called as it is on the iPhone.
You don't need to set self.parentViewController at all, as it is done for you in the presentModalViewController method (the one your use to display the modal view controller)
try checking the value of [theUIView isFirstResponder]
it should be True for the view that has the focus of the keyboard, etc.
I've been having some issues with calling -becomeFirstResponder on a UITextField contained with a view controller that is presented modally. I call this method in the modal view controller's -viewDidLoad method so that the keyboard is immediately displayed. What I expected is for both the keyboard and the modal view controller to animate from up the bottom of the screen at the same time. However, what I'm observing is the following:
There is a ~0.2 second UI lag between clicking the button that calls the -presentModalViewController:animated: method on the parent view controller and when the child view controller begins to animate modally.
The keyboard is immediately presented with absolutely no animation as soon as the modal view controller's animation begins.
Once the modal view controller's animation is complete, everything else seems to operate smoothly.
Dismissing the modal view controller results in it being smoothly animated off screen (along with the keyboard, coincidentally).
Clicking the button that presents the modal view controller any time after the first time results in the same pattern except that there is no ~0.2 second UI lag.
It's as if the keyboard's animation and the modal view controller's animation are both competing for some lower-level Core Animation resource at the same time, but I don't see why this should be happening. What further seems to corroborate this hunch is if I don't ask the UITextField to become the first responder (i.e., if I don't ask the keyboard to present itself), then there is absolutely no UI lag, and the modal view controller animates instantly.
Interestingly, if I do something like [self.textField performSelector:#selector(becomeFirstResponder) withObject:nil afterDelay:0.0001]; then the animation of the keyboard happens nearly at the same time as the modal view controller's animation -- it's extremely difficult to tell that they aren't both being animated at the exact same time when running on the iPhone Simulator. However, when running on an actual device, it's easily noticeable that the keyboard doesn't appear until after the modal view controller is presented. Importantly, though, there's no more UI lag.
Has anyone experienced anything similar to this?
I believe you're having problems because you're effectively stacking animations. The keyboard view is contained by the modal view. The keyboard view is trying to animate its slide in transition within the context of a view which is itself animating a slide in transition. The keyboard animation is trying to hit a moving target.
The pause is most likely the run time of the keyboard transition animation. I am fairly certain the the keyboard animation seizes priority from other animations so that it can drive the rearrangement of the UI e.g. scrolling a table so that the keyboard does not overlay the edited table row. In any case, the keyboard animation occurs within the context of the superview. This is especially true in the case of modal view.
So, the keyboard view animates itself sliding in but because the superview is not actually visible yet, you see nothing. When the superview does slide in, the keyboard is already present because its animation was completed before the superview started its animation.
In short, I don't think you can actual accomplish what you want to do. Instead, I think you will have to animate the modal view transition first, then run the keyboard animation or you will have to accept having the keyboard immediately visible.
I think that Cirrostratus' suggest above is a good one. Use an image of the keyboard that will slide in with the modal view and then immediately swap it out with the real keyboard.
The delayed keyboard animation bothered me as well. viewDidLayoutSubviews was the magical method I was looking for. Placing the becomeFirstResponder call there makes the keyboard slide up in time with the modal.
https://stackoverflow.com/a/19517739/3618864
Try moving your code that sends becomeFirstResponder out of viewDidLoad and into viewWillAppear. I think it is starting too early, you want the keyboard animation to happen when the view appearing animation happens.
Are you saying that you are seeing lag on the Simulator but not on the device? If that's the case you might be seeing a lag due to your computer taking it's time loading everything into memory. When loading up the Simulator the first time it's not just running the code natively, it's probably loading all manner of runtime and debugging libraries. Once loaded into memory the system is probably rather fast. If you are experiancing lag on the Simulator maybe some more RAM in your dev machine might help. If your machine is a few years old you might think about going for something new.
This is what I did to make the keyboard appear to animate exactly the same time as a modalviewcontroller:
In the (init) method of the view being presented modally, I created the UITextField and made it the first responder. Then when I present the modal view controller with animation they both appear at the same time.