gpt4 book ai didi

swift - 我的 scrollViewDidScroll 函数没有收到调用

转载 作者:搜寻专家 更新时间:2023-10-31 08:13:45 27 4
gpt4 key购买 nike

我正在尝试检查用户是否在我的应用上上下滚动,但它没有调用我的 scrollViewDidScroll 方法

当我在应用程序上上下滚动时,为什么它不打印 received scroll 有什么想法吗?

import UIKit

class CreateAccount: UIViewController, UITextFieldDelegate, UIScrollViewDelegate {

@IBOutlet weak var scrollViewer: UIScrollView!
@IBOutlet weak var usernameTextField: UITextField!
@IBOutlet weak var emailTextField: UITextField!
@IBOutlet weak var passwordTextField: UITextField!
@IBOutlet weak var reenterPasswordTextField: UITextField!

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}

override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}

func scrollViewDidScroll(scrollView: UIScrollView) {
print("received scroll")
}

}

enter image description here

最佳答案

添加 ScrollView 委托(delegate)。每当你实现一个委托(delegate)方法时,你需要告诉它使用哪个 Controller ,通常是 self。它让我抓狂了几次。

override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
scrollViewer.delegate = self
}

关于swift - 我的 scrollViewDidScroll 函数没有收到调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39549398/

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