ios - 在情节提要中注册笔尖
问题描述
我对编程和 swift 不熟悉,并且适合初学者使用 iOS 13。我已按照所有步骤操作,但不知道如何解决这个问题。该应用程序无法在模拟器中完成启动并卡在启动屏幕上。“无法使一种视图出队:带有标识符标头的 UICollectionElementKindSectionHeader - 必须为标识符注册一个 nib 或一个类,或者在情节提要中连接一个原型单元”错误是在应用程序委托中,我无法弄清楚我将在哪里注册一个笔尖。错误在类声明行。
import UIKit
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}
我觉得错误是此代码中连接到委托的内容。
import UIKit
class ExploreViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: "header", for: indexPath)
return headerView
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
20
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "exploreCell", for: indexPath)
return cell
}
@IBOutlet weak var collectionView: UICollectionView!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
@IBAction func unwindLocationCancel(segue:UIStoryboardSegue){
}
}
解决方案
推荐阅读
- html - 有没有更简单的方法来检查表单中的密码和重复密码是否匹配?
- python - 如何修复“在此服务器上找不到请求的 URL”apache2 + django + ec2?
- javascript - 使用 ssl 运行 socket.io
- angular - 如何在 Ionic 4 Cordova 中修复“无法确定任务 ':app:preDebugBuild' 的依赖关系”
- android - android dex文件头中校验和和签名的目的是什么?
- python - 这个函数变量如何持续到 Python 中的下一次调用?
- php - Eclipse:PDO“找不到驱动程序”,即使它已安装并启用
- javascript - 如何修复作为对象对象进入html下拉列表的json代码
- javascript - 离子(角度)从数组中获取正确的数据
- python - Python 排序方法