nativescript-dialog
nativescript-dialog copied to clipboard
TypeError: result.dialog.dismissAnimatedCompletion is not a function
Hi,
I try to set up the dialog for iOS, but I always get the following error when I try to close the dialog after an http request has finished: TypeError: result.dialog.dismissAnimatedCompletion is not a function. (In 'result.dialog.dismissAnimatedCompletion(true, null)', 'result.dialog.dismissAnimatedCompletion' is undefined)
This is what I am doing:
exports.showActivityIndicatorDialog = function() {
if(platform.device.os === platform.platformNames.ios){
nativeView = UIActivityIndicatorView.alloc().initWithActivityIndicatorStyle(UIActivityIndicatorViewStyle.UIActivityIndicatorViewStyleGray);
nativeView.startAnimating();
} else if(platform.device.os === platform.platformNames.android){
nativeView = new android.widget.ProgressBar(application.android.currentContext);
nativeView.setIndeterminate(true);
nativeView.setPadding(0, 0, 0, 30); //left, top, right, bottom
}
dialog.show({
message: "Some message",
cancelButtonText: "",
nativeView: nativeView
}).then(function(result){
console.log(result);
});
};
exports.closeActivityIndicatorDialog = function() {
try {
dialog.close();
} catch(e) {
console.log(e);
}
};
So when any http-request in my app has finished, I try to call the closeActivityIndicatorDialog function. My testing environment:
- Telerik AppBuilder 3.7.0
- NativeScript 2.5
- tns-core-modules: 2.5.2
- nativescript-dialog: 0.1.0
- iPhone 4S with iOS 8.4
Everything works fine on Android. Does anybody know what is going wrong here on iOS?
Best regards, Felix
It is broken code, I just traced it down myself.
@enchev - The actual function should be dismissViewControllerAnimatedCompletion
not dismissAnimatedCompletion
@enchev - Another issue with the manual close routine is the promise should be resolved in the
dismissViewControllerAnimatedCompletion
completion callback, not outside of it. Otherwise if you attempt to navigate in the promise after you call the close, you are dead...
This is my version of the close routine; it
exports.close = function () {
if(result){
if(result.dialog instanceof SDCAlertController){
result.dialog.dismissViewControllerAnimatedCompletion(true, function() {
if(result.resolve instanceof Function){
result.resolve(true);
}
});
}
}
}
Can you say when the fix will get officially released?
Please run this PR. https://github.com/enchev/nativescript-dialog/pull/16
This is now fixed in https://github.com/nstudio/nativescript-dialog and our fork of this can be easily installed using tns plugin install @nstudio/nativescript-dialog