gpt4 book ai didi

ios - 使用 Uisearchbar 加载时 Uiview 崩溃

转载 作者:行者123 更新时间:2023-11-30 11:45:29 25 4
gpt4 key购买 nike

我正在设计一个带有搜索栏的 View ,每当我加载该 View 时它就会崩溃。设计如下

enter image description here

我收到的错误如下

*Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setImage:]: unrecognized selector sent to instance 0x153e646f0' * First throw call stack: (0x182303164 0x18154c528 0x182310628 0x18bc7e188 0x182308b10 0x1821edccc 0x18b990b80 0x18b98f0d0 0x18be68870 0x18bffe380 0x18bffe4f8 0x18bffe0b8 0x18bb8b74c 0x18bffe380 0x18bffe4f8 0x18bffe0b8 0x18bb8b74c 0x18bffe380 0x18bffe0b8 0x18be506c8 0x18bffe380 0x18bffe4f8 0x18bffe0b8 0x18be4fa08 0x18bc2cbe0 0x18b9da8e8 0x18b8bd6a8 0x18b8bd5d8 0x18b9df878 0x18b9df564 0x18b9df3c0 0x18b9e1938 0x18ba953c8 0x18b8f25cc 0x18ba950f8 0x18b8f25cc 0x18b8f254c 0x18b8dd0f4 0x18be6180c 0x18b8f25cc 0x18b8f254c 0x18b8dd0f4 0x18b8f1e40 0x18bf4d5e4 0x18bf48b94 0x1822aacdc 0x1822a8694 0x1822a8c50 0x1821c8c58 0x184074f84 0x18b9215c4 0x100294ee8 0x181ce856c) libc++abi.dylib: terminating with uncaught exception of type NSException

View Controller类代码如下

    import UIKit

class SearchStoreViewController: UIViewController {

override func viewDidLoad() {
super.viewDidLoad()

print ("Search Loaded")


// Do any additional setup after loading the view.
}

override func viewWillAppear(_ animated: Bool) {

//super.viewWillAppear(animated)

//self.tabBarController?.navigationItem.title = DASHBOARD_SEARCH_VIEW_TITLE

}

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


/*
// MARK: - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/

}

经过一番研究,我发现是 SearchBar 导致了问题。如果删除搜索栏, View 加载正常。谁能帮我解决这个问题。

最佳答案

当您从搜索结果中设置图像时,请验证您是在 UIImageView 类型而不是 UIView 类型上调用 seImage: .

This error itself says that you are setting an image using UIView type object that is not possible, bcoz UIView doesn't has setImage

同时检查IBOutlet连接是否连接到UIView或UIImageView。

关于ios - 使用 Uisearchbar 加载时 Uiview 崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48880604/

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