gpt4 book ai didi

swift - UIRefreshControl 在下拉时崩溃 - Uncaught Exception Swift

转载 作者:搜寻专家 更新时间:2023-11-01 05:59:26 25 4
gpt4 key购买 nike

我正在尝试在我的 TableView 应用程序中实现下拉刷新功能。但是,当我运行该应用程序时,一旦我下拉刷新页面,它就会崩溃。我在控制台中收到以下消息:

2014-09-30 21:13:15.799 SimpleText[2031:601545] 17545849:_UIScreenEdgePanRecognizerEdgeSettings.edgeRegionSize=13.000000
2014-09-30 21:13:45.296 SimpleText[2031:601545] -[SimpleText.TimelineTableViewController loadData:]: unrecognized selector sent to instance 0x14d50d5e0
2014-09-30 21:13:45.300 SimpleText[2031:601545] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SimpleText.TimelineTableViewControllerloadData:]: unrecognized selector sent to instance 0x14d50d5e0'
*** First throw call stack:
(0x189402084 0x198fb40e4 0x189409094 0x189405e48 0x18930b08c 0x18da6cb98 0x18da55dd8 0x18dba6834 0x100869158 0x100869118 0x100872320 0x100869118 0x10087cae4 0x10086af7c 0x10086cec8 0x1893b98dc 0x1893b7984 0x1892e5664 0x1923175a4 0x18da9e164 0x1001128b0 0x1001129bc 0x19962aa08)
libc++abi.dylib: terminating with uncaught exception of type NSException

这让我感到困惑,因为我不认为错误处理是 swift 的一部分,但它告诉我异常未被捕获?

这是我的刷新代码的样子:

override func viewDidLoad() {
super.viewDidLoad()

refreshControl = UIRefreshControl()
refreshControl!.attributedTitle = NSAttributedString(string: "Pull to refresh")
refreshControl!.addTarget(self, action: "loadData:", forControlEvents: UIControlEvents.ValueChanged)
self.tableView.addSubview(refreshControl!)

//refresh posts when app is loaded
self.loadData()
}

最佳答案

去掉“loadData:”中的冒号

    refreshControl!.addTarget(self, action: "loadData", forControlEvents: UIControlEvents.ValueChanged)

还要确保 loadData 未标记为私有(private)方法。

关于swift - UIRefreshControl 在下拉时崩溃 - Uncaught Exception Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26129459/

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