nativescript-cfalert-dialog
nativescript-cfalert-dialog copied to clipboard
iOS: problem with programmatically close the dialog
Which platform(s) does your issue occur on?
- iOS 13
- iPhone 7
I'm using this plugin for iOS. All work fine, except that when I want programmatically close the dialog.
If I call "dismiss" the dialog close, but the app freeze, while if I click on the dialog button close all work fine. Need to declare something else?
Thanks
Can you show me the code of how you are dismissing the alert? At what point in the code?
Ty for fast answer
let cfalertDialog = new CFAlertDialog(); let config: {..} cfalertDialog.show(config); cfalertDialog.dismiss();
The dialog go away but something go wrong with the app, while if I click on cancel it is all ok.
Well I think is better If I paste the full code:
`public CreateConfirm(options: any): Promise<boolean>
{
return new Promise((resolve, reject) =>
{
let cfalertDialog = new CFAlertDialog();
let config: DialogOptions = {
// Options go here
dialogStyle: CFAlertStyle.ALERT,
title: options.title,
message: options.message,
cancellable: false,
onDismiss: function (dialog) {
resolve(false)
},
buttons: [{
text: "INVIA", // title
buttonStyle: CFAlertActionStyle.POSITIVE,
buttonAlignment: CFAlertActionAlignment.JUSTIFIED,
onClick: function ()
{
resolve(true);
}
},{
text: "ANNULLA", // title
buttonStyle: CFAlertActionStyle.DEFAULT,
buttonAlignment: CFAlertActionAlignment.JUSTIFIED,
onClick: function ()
{
resolve(false);
}
}]
}
cfalertDialog.show(config);
this.dialog = cfalertDialog;
});
}
public Close(): Promise<boolean>
{
return new Promise(async(resolve, reject) =>
{
if (this.dialog !== null)
{
this.dialog.dismiss();
this.dialog = null;
}
resolve(true);
});
}`
Other infos that can be useful:
result = await this.DialogResume();
console.log("Action on dialog);
public async DialogResume(): Promise<boolean>
{
const result = this._lastDialog.CreateConfirm({
title: "This is the title"
message: "This is the message"
});
return result;
}
I notice that I receive this exception:
Unbalanced calls to begin/end appearance transitions for <UIViewControllerImpl: 0x15dea9ae0>.
update: if i write this.dialog.dismiss(true); it work!
@Atomico001 Yes, it mentioned in the readme that the dismiss function takes a boolean as the parameter. And it doesn't have a default value in the code. You have to pass a boolean to it.
Hi @shiv19 i was trying all time with this.dialog.dismiss(false); and it didn't worked. Only with true work.
That is weird! Thanks for reporting this :)