Disabling view animation during a segue (or vice versa) - ios

I have a rightBarButtonItem that slides up a view from the bottom of the screen like a UIActionSheet, and everything works fine except when I press a button that pushes a UIViewController and the rightBarButton almost at the same time, the two will both execute, thus resulting in a slide-up view over a screen that is totally unrelated.
Is there a way to get some notification or something so I can stop the view from animating when a view controller is being pushed, or the other way around?

With no code snippets its hard to understand what you are doing to cause this behavior. To me it sounds like you just need to restructure your button target actions. Why would u want to slide your button up from the bottom and push a VC at the same time if that will just hide the previously slid rightBarButton. Maybe just remove the slider code from the target action when that VC gets pushed.
There is a method you can call to stop animations your probably aware of.
- pushViewController:Animated:

Related

Swift Default Swipe Back - Animation

i am trying to make a swipe back animation in my App. It is working completely fine, but there are two problems I have.
The First one is, that the back swipe is working on the complete page and not only on the left side of my display.
And the second questions is, how can I have this normal back swipe animation. In my App it directly pops up.
At the moment I am only using ViewController and to switch between them I use a button with perform segue. But to get back to the pervious page I would like to use this default swipe back animation Apple is having.
Well there are multiple things happening.
the best way to handle this is to embed your first view controller inside UINavigationViewController. You can then push your second view controller and so you will get that Apple back-animation for free.
if you don't want to use NavigationController, you can at least replace that swipe recognizer with UIScreenEdgePanGestureRecognizer, so it will trigger only near the edges of screen. But it will still just pop instantly. You can't easily replicate that back animation... you'd need to use custom transition with
UIViewControllerTransitioningDelegate. And that's not easy.
My advice: learn more about UINavigationController and use it.

Transition of a view controller embedded in a navigation controller

I have a problem with a transition. I am modifying this project https://github.com/xxxAIRINxxx/MusicPlayerTransition in order to have the transition from the right instead of the bottom. This part is fine. My transition comes from the right.
My problem is that I'm embedding the presented modal view controller into a Navigation Controller. I do this so I can use the "pushViewController" function when I click on a cell of my modal view controller.
My hierarchy is as follow. I have a dashboard. From the right, I drag a TableViewController X. If I drag back in the opposite direction, I come back to my dashboard. Fine. Now, If I tap a cell, it pushes a new ViewController Y.
Now, if I am in my new ViewController Y and that I drag back, I come back directly on my dashboard instead of going back to my TableViewController X, as a natural navigation controller should behave.
I did a small project on github that does only that, so you can easily see my entire code.
https://github.com/magohamote/NavigationControllerTransition.git
I understand why it behaves like this, but I would like to know how I can override the transition set on the navigation controller in order to have the normal behaviour of my navigation controller once it is presented.
Another problem I have not been able to solve. On the project I used as a starter (the one from xxxAIRINxxx) the transition is perfectly smooth. On mine, the first time I trigger the transition, it blinks and get stuck. Once I did it once, it is smooth the next time I drag my view. But the first time is always awful. I don't know why either :(
Thank you a lot for your help!

Touching an area of screen dismisses view controller

I've never seen a problem like this until now. When I first updated my app, this problem did not exist. It was fine. Since then there've been a couple of iOS updates, so it's possible this is where the problem began.
I basically have a few view controllers that proceed like a wizard from one step to the next, by either clicking back/cancel button or the next button.
There's a textView covering the main area.
Normally by touching inside the textView it would begin editing.
On this viewcontroller it's fine, that works. No problem.
On this viewcontroller and every subsequent view controller including tableviews with options to select, if you touch anywhere underneath the cancel and next buttons inside the view controller, it dismisses the view controller and goes back to the previous screen. There doesn't appear to be anything executed in my code when this happens. It just dismisses the view controller as if one pressed the back button. I know the back button code is not being executed because I printed a line in there.
The next view controller is a tableView and does not have a textView. It's got nothing to do with the textView. It just dismisses if I touch anywhere on the screen other than the next or cancel buttons. The next views are the exact same way. It's like a big invisible button is in the way of the screen blocking any interaction with the top half.
What's going on here? How do I fix this? It has never done this before and I didn't change anything.
Turns out that this was caused by using page curl transitions. I changed it to flip horizontal and it works now. Page curl transitions are obviously bugged currently.

Created custom UINavigationController - using the iOS 7 swiping gesture doesn't work properly

So I had created a very simple custom NavigationController a couple years ago, of course it subclasses UINavigationController and the only method it overrides is
- (BOOL)navigationBar:(UINavigationBar *)navigationBar shouldPopItem:(UINavigationItem *)item
in it I show a UIAlertView asking the user to make sure they want to go back. When they select yes it goes back using
[self popViewControllerAnimated:YES];
Everything is working right except for with iOS 7 when using the new swiping from left to right gesture to go back to the previous screen.
It correctly goes back to the previous screen however the top navigation bar doesn’t change.
For example if I’m on my main screen and I click on Row1. The view will change and the nav bar will display Row1 as the title and a ‘< Back’ button on the top left.
Clicking on the ‘< Back’ button works 100% as expected.
If I swipe left to right to go back, the view will go back to my main screen however the nav bar will still be showing the ‘< Back’ button and ‘Row1’ as the title.
I tried just using UINavigationController instead of my custom class which subclasses it and the swiping features work correctly so I know that’s the problem. I must be missing a call or something in my custom class
Any ideas?
Thanks!
EDIT:
I just edited my CustomNavigation code a bit and it now seems to work. When using the top left Back button for some reason shouldPopItem was getting called twice, so I had some code to make it work correctly with iOS 6 and lower.
When using the swipe gesture I noticed that it was only being called once and the first time I was popping the controller but returning NO (which was why the nav bar wasn't changing). I now put a check for iOS 7 and return YES right away which fixed the problem and now works properly.
navigationBar:shouldPopItem: is a delegate method on UINavigationBar, which UINavigationController implements. So all you're doing is stopping the navigation bar from popping a UINavigationItem. That's why when you override this that it prevents the navigation bar from removing the item associated with the UIViewController being popped. It shouldn't actually ever prevent the navigation controller from popping a view controller, and it was probably just a side effect of the old implementation that made it work right. Either they changed something, or there's just a difference with how it works when the gesture is used, that makes this hack no longer work right. Anyway, generally you're not supposed to be able to prevent the back button from going back. If you want to present a screen that requires some kind of confirmation to go back, or a task to be completed or cancelled first, you should present a modal view controller instead. Otherwise, you could replace the default back button with your own and hide the normal back button. Then your custom button (which would look different unless you went to a lot of work) could call a custom method to prompt first.
Of course you'll want to disable the pan gesture if you stick with using a UINavigationController. There's a property on UINavigationController to get the gesture recognizer:
#property(nonatomic, readonly) UIGestureRecognizer *interactivePopGestureRecognizer NS_AVAILABLE_IOS(7_0);
You can disable it so that it will no longer make you go back.

UIButton doesn't respond to touch on first load, but works after segueing back from another view controller

I'm not sure when or how this happened in my project, but it did. The main button in the middle of my initial view controller ignores all touch events when I first load the app. The buttons in my navbar on the bottom all work fine.
If I follow one of those buttons through a modal segue to another view controller and then segue back into the initial view controller, the button works perfectly.
I'm at a loss. Any idea how this could have occurred or how I could fix it?
Update
I can't put my finger on what, but this has something to do with my constraints. If I remove them (and my app tumbles into a mess on 3.5 inch phones), the button works at all times.
I have the same problem: on the first load of the view one particular UIButton doesn't work, but if I tap on other tab bar element, launching a segue and then coming back to my home screen, it works perfectly.
My problem persists even if I remove every constraints for the view.
In my case, the POSITION of the button seems to be the cause of the issue: in the right side of the view it becomes not working, but if I move the same button on the center or left of my view it becomes available.
HELP ME/US :-(

Resources