Ionic 3(click)事件进入Modal在iOS中不起作用

时间:2019-06-14 15:45:58

标签: html ios angular ionic-framework ionic3

我迷失了IOS上的问题。 我正在实现一个聊天,其中有一个联系人列表,当您单击其中一个时,它将显示相关消息的列表。 它在Android和浏览器(甚至在IOS浏览器)上也能完美运行,但是在IOS上,当我单击联系人以显示消息时,什么也没发生。 即使我尝试在离子含量的任何位置尝试添加一些测试按钮,也不会从html调用我的函数。它仅适用于我的离子头。

你能救我一命吗?

这是我的代码:

HTML:

<ion-header>
    <ion-toolbar>
        <ion-buttons>
            <button ion-button (click)="displayChat(undefined)">
                Test (works here)
            </button>
        </ion-buttons>
    </ion-toolbar>
</ion-header>
<ion-content class="no-scroll" style="height: 100% !important;">
    <div>
        <button ion-button (click)="displayChat(undefined)">
            Test ?
        </button>
        <ion-list class="contactList">
            <ion-item *ngFor="let chat of chats" 
             (click)="displayChat(chat)">
                {{chat.contactName}}
                 <br>
                <span class="chatDate">
                    {{chat.lastMessageSend}}
                </span>
            </ion-item>
        </ion-list>
        <button ion-button (click)="displayChat(undefined)">
            Test ?
        </button>
    </div>
</ion-content>
<ion-footer>
    <ion-toolbar>
        <ion-title>Footer</ion-title>
        <button ion-button (click)="displayChat(undefined)">
            Test ?
        </button>
    </ion-toolbar>
</ion-footer>

TS:

displayChat(chat: Chat) {
    console.log("Ok");
}

我减少了代码的可读性。

享受!

编辑

.no-scroll .scroll-content {
    overflow: hidden;
}

.chatDate {
    float: right;
    font-size: 0.7em;
}

在页脚中也不起作用。

2 个答案:

答案 0 :(得分:1)

好的,我弄清楚了问题所在。

实际上,这段代码是从Popover程序运行到Ionic Modal中的。

我必须保持打开Popover才能使用OnDidDismiss方法进行某些处理,但是只有当Popover保持打开状态时,它才能执行此方法。

但是,在IOS中(当然),如果弹出框(或可能是任何其他绝对元素)位于模态后面,则不能单击模态。

因此,为了解决此问题,我创建了一个Observable来处理(模态的)OnDidDismiss方法,该方法作为viewCtrl.dismiss方法的参数提供,以使其重新回到Popover视图的OnDidDismiss上,并且然后订阅Observable。

答案 1 :(得分:0)

在按钮组件内,尝试添加离子项目而不是离子按钮。我在工作正常的地方有一些类似的代码。

例如:

stages:
  - build_for_ui_automation
  - independent_job

variables:
  LC_ALL: "en_US.UTF-8"
  LANG: "en_US.UTF-8"

before_script:
  - gem install bundler
  - bundle install

build_for_ui_automation:
  dependencies: []
  stage: build_for_ui_automation
  artifacts:
    paths:
      - fastlane/screenshots
      - fastlane/logs
      - fastlane/test_output
      - fastlane/report.xml
  script:
    - bundle exec fastlane ui_automation
  tags:
    - ios
  only:
    - schedules
  allow_failure: false

# This should be added and trigerred independently from "build_for_ui_automation"
independent_job:
  dependencies: []
  stage: independent_job
  artifacts:
    paths:
      - fastlane/screenshots
      - fastlane/logs
      - fastlane/test_output
      - fastlane/report.xml
  script:
    - bundle exec fastlane independent_job
  tags:
    - ios
  only:
    - schedules
  allow_failure: false

让我知道之后会发生什么!随时准备提供帮助。