gpt4 book ai didi

ios - viewWillAppear(_ :) viewDidDisappear(_:) View SwiftUI

转载 作者:行者123 更新时间:2023-12-01 15:34:53 26 4
gpt4 key购买 nike

我想从 viewWillAppear(_:) 上获取数据
SwiftUI 中是否有任何相同的方法或修饰符可用?
还有 viewDidDisappear(_:) 的任何修饰符

最佳答案

当然有

@available(iOS 13.0, OSX 10.15, tvOS 13.0, watchOS 6.0, *)
extension View {

/// Adds an action to perform when this view appears.
///
/// - Parameter action: The action to perform. If `action` is `nil`, the
/// call has no effect.
/// - Returns: A view that triggers `action` when this view appears.
@inlinable public func onAppear(perform action: (() -> Void)? = nil) -> some View


/// Adds an action to perform when this view disappears.
///
/// - Parameter action: The action to perform. If `action` is `nil`, the
/// call has no effect.
/// - Returns: A view that triggers `action` when this view disappears.
@inlinable public func onDisappear(perform action: (() -> Void)? = nil) -> some View

}

关于ios - viewWillAppear(_ :) viewDidDisappear(_:) View SwiftUI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59014980/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com