作者:小木马 | 来源:互联网 | 2023-09-13 19:02
Describe the bug
I would like to display an entry, and enqueue another one to be displayed after. But when I call the functions consecutively, entry does NOT appear. (The background of the entry is applied, but the entry does not appear)
To Reproduce
Steps to reproduce the behavior:
1 2 3 4
| swift
SwiftEntryKit.display(entry: firstEntry, using: attributes)
attributes.precedence = .enqueue(priority: .normal)
SwiftEntryKit.display(entry: secondEntry, using: attributes) |
Expected behavior
First entry is shown, and when it is dismissed, the next one in queue should appear.
iPhone (please complete the following information):
- Device: iPhone 7, iPhone Xs
- iOS Version: iOS 12, iOS 13
- Xcode Version 11.1
- SwiftEntryKit Release # 1.2.0
该提问来源于开源项目:huri000/SwiftEntryKit
I tried to build an example that would fail, and I could not reproduce the error. I looked into the source, and found that when reusing the view (and assigning label text differently), it yielded the same error.
When I recreated the view every time, it worked fine! Thanks for trying to help.
Below is the code that would yield the empty view.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| swift
import UIKit
import SwiftEntryKit
class ViewController: UIViewController {
private var attributes: EKAttributes = .init()
private var width: CGFloat? = nil
private var entryA = EntryA()
func startDemo(_ sender: UIButton) {
startDemo()
}
override func viewDidLoad() {
super.viewDidLoad()
width = view.safeAreaWidth
}
private func startDemo() {
showEntryA()
DispatchQueue.main.asyncAfter(deadline: .now() + 3.0, execute: {
self.showEntryBandEnqueueA()
})
}
private func showEntryA() {
attributes = .bottomFloat
attributes.screenBackground = .color(color: EKColor.black.with(alpha: 0.7))
attributes.entryBackground = .color(color: .white)
attributes.displayDuration = .infinity
attributes.screenInteraction = .dismiss
attributes.entryInteraction = .dismiss
attributes.entranceAnimation = .init(translate: .init(duration: 0.3, delay: 0.2, spring: .init(damping: 0.9, initialVelocity: 0)))
attributes.exitAnimation = .init(translate: .init(duration: 0.2), fade: .init(from: 1.0, to: 0.0, duration: 0.2))
attributes.positionConstraints.verticalOffset = 0
attributes.positionConstraints.size = .init(width: .constant(value: width!), height: .intrinsic)
attributes.statusBar = .ignored
attributes.positionConstraints.safeArea = .empty(fillSafeArea: true)
entryA.titleLabel.text = "FIRST OPEN"
SwiftEntryKit.display(entry: entryA, using: attributes)
}
private func showEntryBandEnqueueA() {
attributes = .bottomFloat
attributes.screenBackground = .color(color: EKColor.black.with(alpha: 0.7))
attributes.entryBackground = .color(color: .white)
attributes.displayDuration = .infinity
attributes.screenInteraction = .dismiss
attributes.entryInteraction = .dismiss
attributes.entranceAnimation = .init(translate: .init(duration: 0.3, delay: 0.2, spring: .init(damping: 0.9, initialVelocity: 0)))
attributes.exitAnimation = .init(translate: .init(duration: 0.2), fade: .init(from: 1.0, to: 0.0, duration: 0.2))
attributes.positionConstraints.verticalOffset = 0
attributes.positionConstraints.size = .init(width: .constant(value: width!), height: .intrinsic)
attributes.statusBar = .ignored
attributes.positionConstraints.safeArea = .empty(fillSafeArea: true)
entryA.titleLabel.text = "SECOND OPEN" // |