Ionic2 Alert不显示弹出窗口是否处于活动状态



我有一个列表,用户可以从列表项调用弹出窗口。在弹出窗口中,当一个选项被选中时,应该创建一个确认警报。

问题是当我尝试调用警报时弹出窗口打开,它不正确显示。它似乎在列表后面,列表变得无响应(不能再接受点击)…

对于测试建议,如果我直接从点击项中添加警报,而不是从弹出窗口中选择的选项,警报将正确显示。

在创建列表和弹出窗口的页面上:

public OnItemOptionsPress(event, item)
  {
        event.stopPropagation();
        let popoverOptions =
        [
              { 
                    Resource: "Remove",  
                    Icon: "icon-trash",               
                    Callback: (event, item) => 
                    { 
                          this.confirmRemoveItem(event, item) 
                    },
              }
        ];
        let popover = this.PopoverController.create
        (
              PopoverOptions, 
              { 
                    Owner: item, 
                    Items: this.popoverOptions 
              }
        );
        popover.present({ ev:event });
  }
  public confirmRemoveItem(event, item)
  {
        let alert = this.AlertController.create
        (
              {
                    title: 'Remove Item',
                    message: 'Do you want to remove?',
                    buttons: 
                    [
                          {
                                text: 'No',
                                role: 'cancel',
                                handler: () => 
                                {
                                      console.log('No has been clicked');
                                }
                          },
                          {
                                text: 'Yes',
                                handler: () => 
                                {
                                      console.log('yes has been clicked');
                                      this.removeItem(item);
                                }
                          }
                    ]
              }
        );
        alert.present();
  }
  public removeItem(item)
  {
        this.items.splice(item.Index, 1);
  }

当一个选项被选中并且close函数被调用时,在弹出窗口内部:

  public close(event, item) 
  {
        if (item.Callback) item.Callback(event, this.Owner);
        this.ViewController.dismiss();
  }

我注意到解散()方法返回一个承诺。我不得不在关闭弹出窗口和调用async回调时添加延迟。

  public close(event, item:PopoverItemModel) 
  {    
        let animation = this.ViewController.dismiss();
        animation.then(()=>
        {
               if (item.Callback) item.Callback(this.Owner);
        });
        //if (item.Callback) item.Callback(this.Owner);
  }

现在它工作了…但是有一个奇怪的延迟(弹窗完成动画并被解散的时间)。可能视图控制器不能同时处理多个动画/组件过渡…

相关内容

最新更新