I have one modal where there is a function executed each seconds.
When I call modal.dismiss, in the console log I can see the function is still executed.
I don't know why the modal is not totally removed and destroy after been dismissed.
Any help is welcome.
Alex.
Here is my answer :
if(this.intervalTimer) {
clearInterval(this.intervalTimer)
}
Modal was destroyed from the dom but I was forgetting to clear the Interval..
Related
I have installed cooapods and SVProgressHub. I am unable to figure out how to show the SVProgressHUB loading screen.
SVProgressHUD.show()
This is inside my view controller.
I am new to swift and stack overflow. Cheers!
You can Popssibly Try this:
SVProgressHUD.setDefaultStyle(.custom)
SVProgressHUD.setDefaultMaskType(.custom)
SVProgressHUD.setForegroundColor(UIColor.red) //Ring Color
SVProgressHUD.setBackgroundColor(UIColor.yellow) //HUD Color
SVProgressHUD.setBackgroundLayerColor(UIColor.green) //Background Color
SVProgressHUD.show()
The output:
Cheers!
Its not clear what you are asking, are you looking to call SVProgressHUD during the splash screen ? or when the first view controller is opening.
If there is nothing being processed between when you call .show and when you call .dismiss, it simply might not be seen, even though you are making the calls.
In AppDelegate didFinishLaunchingWithOptions you can place some defaults
SVProgressHUD.setBorderColor(kBrandBlue)
SVProgressHUD.setBorderWidth(1.0)
SVProgressHUD.setCornerRadius(44.0)
SVProgressHUD.setForegroundColor(.blue)
SVProgressHUD.setRingThickness(4.0)
SVProgressHUD.setGraceTimeInterval(0.5)
I'm not sure what the default grace timer is, but you might want to check that.
If you call .show and dont call .dismiss, then it will keep spinning forever, so just put the .show in viewDidLoad for your ViewController and see if it comes up.
Hope that helps
I'm struggling to find a way to execute a function in the main controller when it loads. When the main controller is loaded the first time, I can get that function executed inside onInit. But the issue is when user logs out and logs back in the main controller, the method onInit does not get executed again. Is there a way to execute a function every time when controller loads?
Below code will help you to achieve what your are looking for
onInit: function() {
this.getRouter().getRoute("routeName").attachPatternMatched(this._onObjectMatched, this);
}
_onObjectMatched: function() {
//this function executes every time you navigate to this page
}
Demokit link for detailed information
What do you mean by "when user logout and log back in the Main Controller"?? When your app loads the view the first time, it executes the onInit, onBeforeRendering, onAfterRendering and other lifecycle events. But if you don't destroy the controller instance you never 'log out' of it. It remains there as an object in your DOM and their functions can be called whenever is needed.
Now, if you are using the UI5 Router to navigate back and forth to other views, then I suggest you to set 'PatternMatched' events in your router. This events will be fired whenever the given pattern is match, no matter if it is the 1st or the n-th time.
Check out:
read optional url parameters
Step 32: Routing with Parameters
I have a modal in my Ionic 2 app. In this modal, clicking on a button, a confirmation prompt ("Are you sure?") pops up. By clicking yes, I do certain operations, then dismiss the modal by calling this method:
close() {
this._viewCtrl.dismiss();
}
and _viewCtrl is the property of my class, which i defined this way in the constructor:
constructor(
public _nav: NavController,
public _viewCtrl: ViewController,
public _profile: Profile,
params: NavParams) { ... }
My problem is that behind the modal I have a "3 Tabs Page", sort of. All works well, the 3 tabs are just fine, my modal is ok, it dismisses as it should, the problem is that when the modal is dismissed the 3 tabs break! They freeze on the second tab (which is the one that calls the modal)! Even if I click on tab 1 and 3, I see only the content for tab 2, and I can do nothing.
I'm pretty sure the operations before the dismiss shouldn't be a problem. I found that if I comment out the this.close(); part, and everything goes fine! The modal doesn't close, but I can close it by hand (with the same function, that's the strange thing!) then I return to the tabs page and the tabs are just fine.
What is happening to the app?
PS. No error is shown in the console!
If you check in the console you will see the modal overlay is still there. That's why when you click on any button on your app, you got no reaction cos you click on the transparent overlay.
I had similar issue now, where I had the dismissal of a Modal working before with Ionic 2 Beta 6, but on the latest Beta 10 it isn't working anymore.
How my logic worked was:
Do server call (while displaying progress with the Loading component
When call returns from server, then dismissing the Loading and then the Modal, but calling them in a synchronous fashion
Now this doesn't work with latest Beta. What I had to do was:
this.loading.onDismiss(() => {
this.viewController.dismiss();
});
this.loading.dismiss();
I got this workaround from here:
https://github.com/driftyco/ionic/issues/6325
After some research on the web without success, I come here to ask you the question about my warning.
Actually, I have a view V1 with a navigation controller and I want to push a modal view V2 when V1 has finished loading.
So I use the performSegueWithIdentifier method (I'm using storyboard).
Here is my code:
[self performSegueWithIdentifier:#"showConnexionViewSegue" sender:self];
And when I compile, I got this warning:
Unbalanced calls to begin/end appearance transitions for <UINavigationController: 0x6849b30>
Can anyone help me?
It sounds like you may be performing the segue in -viewWillAppear: thus generating two -viewWillAppear: messages without 2 corresponding -viewDidAppear messages.
Try performing the segue in -viewDidAppear.
I had this problem, but what I had done is on a UIViewController I had linked a Segue from a UIButton and also coded it into a nextBtnPressed: function, so I was actually pushing two new UIViewControllers on the one button press. Limiting it to just the one segue fixed it. But it took some investigating to see that I had done this double up.
'Unbalanced calls to begin/end appearance transitions for '
Says an animation is started before the last related animation isnt done.
So, are you popping any view controller before pushing the new one ?
Or may be popping to root ? if yes try doing so without animation
i.e. [self.navigationController popToRootViewControllerAnimated:NO];
And see if this resolves the issue, In my case this did the trick.
The reasons for this are manifold and are very specific to the context and the programming. For example, what I was doing was
initialising a sound file, playing it (asynchronously) for 1.4 seconds,
making an image move across the screen using animation timed to last 1.4 seconds and,
with a timer set to 1.4 seconds after step 2, pushing a viewcontroller.
What i discovered is that if I DO NOT have the instructions for these 3 steps one after the other (if I mix them up), then I get the error "Unbalanced calls...". Also, if I time the push of the viewcontroller to less than 1.4 seconds, I get the message as well.
So, check that the sequence and timing of your program instructions are correct.
I can't find any documentation to confirm this, but it appears that you can only call the method stringByEvaluatingJavaScriptFromString in overridden methods from a UIWebView delegate. Can anyone confirm this?
Here's what I've tried. I setup a button on a view, link it to a method on my viewcontroller, and make sure it works fine. My view has a UIWebView control on it as well. If I run the project on the simulator or on the iPhone, there are no issues. Then I add this code to the button's method.
[theWebView stringByEvaluatingJavaScriptFromString:#"alert('Hi there!');"];
When I run the project, I can click the button and see the 'Hi there' prompt and I can click OK to dismiss it. Usually 4-5 seconds later the simulator crashes. I occasionally see the "__TERMINATING_DUE_TO_UNCAUGHT_EXCEPTION__" error, but not consistently; sometimes there's no error. It also doesn't always crash the first time. Sometimes I go to another page, and then try it again, and it crashes.
If I put the same code in the webPageDidFinishLoad event it works fine. But I'd like the code to be called when the user demands it so that event doesn't suit my needs.
I'm open to a workaround if you have any ideas? Thanks in advance!
I still don't know the exact reason this didn't work, but I found I could rewrite my code to get called during the UIWebView delegate methods instead.