i have two View Controllers in my project, the first one is for Sign Up view and the second one is for Sign In view. In the first view i have a sign in button which has a segue to the second Sign In view (i.e. if you've an account pass to Sign In view, please see attached image).
Unfortunately, when i clicked sign in button in Sign Up view the second view(Sign In view) not opening.
I'm sure prepareForSegue is called and the button touch is certainly processed(IBAction for the button is called). Also ViewDidLoad of the view supposed to open is called, as you may guess ViewDidAppear of the same view is not called.
In a nutshell, what happens is button and segue is working and the second view is loading but it does not appear and the first view does not disappear. It happens all of a sudden(i.e. it was working properly before), i do not know what did happen or what i did mistakenly. If anybody can help me, it would be a great relief.
*I know, in this case IBAction and prepareForSegue are not necessarily to be used, these were used just to make sure that the button and the segue are working properly.
Related
This question already has an answer here:
Swift 4 Odd unexpected jump back to earlier storyboard
(1 answer)
Closed 4 years ago.
Every time I tap somewhere along the top part of a view controller, it would return to the previous view. Root Controller is not affected as it doesn't have anything to return too. All of my View Controllers are affected though. (Please read update 3)
Things I've tried:
Looked for unnecessary gesture recognizer. (Result: I received nil when I check for the list gestures.)
I figured I might have accidentally added or left a IBOutlet to the view or something. (Result: There was no unnecessary IBOutlets.)
I disabled user interaction from a view to see if it would be affected. (Result: The bug seemed to go away until I enabled user interaction again.)
I've tried to do some research but I wasn't getting the results I wanted.
Tapping above the green line will make the View Controller return to the previous Controller.
I'm still relatively new to Objective-C and Xcode so I don't know if I'm making a rookie mistake or not.
UPDATE (Please read update 3)
Still nothing but here are a few more things i've tried:
Logging every user action.
Created a new project with new view controllers.
Opened a previous project to test it's view controllers.
Uninstalled and reinstalled Xcode.
All attempts still came with that weird bug.
UPDATE 2(Please read update 3)
I've decided to put a band-aid over the problem. Since the bug doesn't work when clicking over a button, I put constraints on a empty button, put it on top of the background image and removed the effect when button is tapped.
I thought this would work but there is a few spots on the screen that activates the bug. I experimented and figured that certain parts of ui elements activated the bug. (Example: Some labels in a Stackview, top part of a textfield, a switch, top part of a UICollectionView, etc.)
I've disabled user interaction for certain ui elements. Unfortunately not all ui elements could be disabled because some require user interaction.
Also I figure out that tapping with three fingers on the screen somehow activates the bug.
Here is an error code I received in the console when I was trying multiple taps on the screen:
<_UISystemGestureGateGestureRecognizer: 0x2822fc1e0>: Gesture: Failed to receive system gesture state notification before next touch
UPDATE 3
After playing around with the code again. I believe I've figured out what is causing the problem but not how to fix it.
I believe it has to do with the story board segue, or at least the transitions being used. If I set the kind to "Show(e.g. Push)" than it works fine, but if I set the kind to "Present Modally" and the transition to "Partial Curl", the bug does it's thing.
Sidenote: This is how I tested it. I created a new project (I don't think the language matters). The project has two view controllers; one button each with segue pointing at each view controllers. Segue 1 has it's kind as "Present Modally" and the transition as "Partial curl". Segue 2 is on the 2nd view controller and has it's kind as "Show(e.g. Push)". To test the bug, tap along the top part of the screen. If the bug worked, then it should show the partial curl transition but in reverse and send the user back to the 1st view controller.
maybe you are experiencing the standard swipe back gesture coming from the navigation controller. It thats the case try this code:
Objective-C:
if ([self.navigationController respondsToSelector:#selector(interactivePopGestureRecognizer)]) {
self.navigationController.interactivePopGestureRecognizer.enabled = NO;
}
Swift:
navigationController?.interactivePopGestureRecognizer?.isEnabled = false
I have noted recently that each of my app view has one particular bug/behaviour: if user taps too fast on a UI component when the view appears, the tap is simply ignored. If the user wait a bit before tapping, the tap works.
Storyboard is used for the storyboard, tap gesture recognisers are on UIImageview and using IOS 10.2.
Through different forums i have read about the following options:
nest the call of "present view controllers" in main thread
Call CFRunLoopWakeup before presentviewcontroller
Add programatically the TapGesturerecognizer
change the states of "delays touches end" and "delays touches began"
disable 3d touch option as similar symptoms was reported to happen in other apps
All above have been unsuccessful.
Anyone would have met similar issues with the first tap just after the view load?
[Update: I realise this misbehaviour is not specific to this app. Two tests to try:
create an xCode Project for iPhone and two view controllers Controller A and Controller B. Two buttons : a button on Controller A view to go to Controller B view and a button Back in Controller B view to go back to Controller A view. Tap to go from View A to B, tap back in B and try immediately to tap on button to go to B. First tap doesn't work either.
Go in Settings of the iPhone. Tap On Notifications. Press On Settings to go back to Main Settings screen, Tap immediately back on Notifications. If fast enough, first tap doesn't work. Second tap works or waiting a bit before first tap.
Question is now: this looks like a common problem across iPhone apps. Would you know if there would be a common setting somewhere? or is this a common bug for given IOS version ?
]
Stephane
This is a general problem (the moment when the view controller is changed, the first tap will be ignored), but this is not a bug that will happen only because the switch view controller's animation has not yet been completed. If you set the animation to false , then the view controller can immediately respond to your click, no matter how fast (anyway faster than your hand) :)
I have a problem in iOS7 where I am calling a segue with performSegueWithIdentifier (I have code just like this that works just about everywhere else), then I log the segue in prepareForSegue, then I log again the view controller (VC) that the segue is supposed to push to the top.
prepareForSegue gets called appropriately and the segue has the correct string as its identifier property. Yet the VC that it is supposed to push to the top never gets initialized nor viewWillAppear gets called.
The segue I am talking about, which is the only one that does not work (all the other ones work in both ios6 and 7), is the one leading form the center VC to the right VC. By the way, this works flawlessly in iOS6.
What could be the cause?
the code:
-(IBAction)gotoMainMenu:(id)sender{
DLog(#"DifferentName");
[self performSegueWithIdentifier:#"DifferentName" sender:self];
}
Get in the habit of not wiring up segue's to buttons. Wire them up to the VC and then in the touchUpInside action, fire off the performSegueWithIdentifier.
I had the same issue and solved it as follows. In view A I had a segue that was triggered by a button (UIButton) and the button was also connected to an action in my controller. When I clicked the button in View A, View B would appear as expected. However, when I tried clicking a button in View B to go to View C nothing happened just as you described above.
In my case the issue was resolved in View A. I removed the segue that was tied to the button and let the IBAction that was associated with the button handle calling the performSegueWithIdentifier, then I created a new manual segue that was only tied to the view and voila things worked as expected again.
In short, I guess make sure you don't have both and action and a segue linked to the same button. Hope this helps.
I have an iPad app with a UISplitviewController set as the root view controller of UIWindow. The master view controller (i.e. the view controller of the left view) is the UISplitViewController's delegate with the delegate method shouldHideViewController returns YES, this means when the app first launches the left view will be hidden and can be shown (and hidden) by the user gesture, i want to show the master view when i navigate to detail pages and prevent the user from hiding it using the gesture, i've tried to call shouldHideViewController method on the delegate to let it returns NO the second time it got called but this time it has no effect, the master view keeps hidden in detail pages and can be shown with the user gesture.
any ideas to achieve showing of the master view with this scenario would be highly appreciated.
This may only be a partial answer because I'm not sure what you mean that you call shouldHideViewController method on the delegate. My understanding is that only the UISplitView should call this method. If you call it, then it will not effect the UISplitView, because it wasn't what made the call. In other words, the delegate method is used by UISplitView to get some information (and allow you a place to do additional things to other stuff) but it is not used as a way to tell the UISplitView what to perform.
Having said that, at least for the gesture activation/deactivation, I would think that in splitViewController:shouldHideViewController:inOrientation: you could do something like
[svc setPresentsWithGesture:NO];
I don't see any way to programmatically tell the UISplitViewController to display or hide the master view controller because the delegate only tells it if it should proceed in presenting or hiding the master when it is going to try and do that. It does seem like there should be a way to do this though.
I'm working on a problem where I have a ViewController which opens a popOver when a button is pressed and then in the popOver you can edit some settings which affect the content shown in the mother ViewController (for instance change the color of the View, change a map or a table there). This can be off course called whenever the popOver is dismissed, but it needs to be live up-to-date.
I tried using delegates, where I can pass over data or call a function but the function won't be started on a ViewController wchich isn't active, right?
I also tried NSNotifications but it didn't work either.
I found several questions like this on stackoverflow, but there is no real answer yet:
UIPopoverController button selecting method of another ViewController but not updating its view iOS
Refresh the view controller from popover
Refreshing a view from a popover
Refresh a WebView in a ViewController from another ViewController
how to refresh or reload a uiviewcontroller
Can somebody please explain a generall way with some code snippets how to get this fixed?
Delegation is a fine solution. The target view controller is presumably still visible underneath the popover (which shouldn't fill the screen). In this case when the target receives the delegate callback it can do any updates and refresh its views to update the UI without any limitation. In this situation both view controllers (the 'target' and the popover) would both be classed as 'active' as they are both visible on screen.