提问人:Johnny Nguyên 提问时间:8/6/2023 最后编辑:Johnny Nguyên 更新时间:8/11/2023 访问量:44
情节提要 (<UIStoryboard: 0x600002c51ec0>) 不包含标识符为“AlphabetController”的视图控制器
Storyboard (<UIStoryboard: 0x600002c51ec0>) doesn't contain a view controller with identifier 'AlphabetController''
问:
@objc func abcPressed() {
DispatchQueue.main.async { [weak self] in
guard let self = self else { return }
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: AlphabetController.storyboardIdentifier) as! AlphabetController
controller.modalPresentationStyle = .fullScreen
self.present(controller, animated: true, completion: nil)
}
}
当我按下 abcPressed 时,出现错误“Storyboard (<UIStoryboard: 0x600002c51ec0>) doesn't contain a view controller with identifier 'AlphabetController”
如何通过代码识别AlphabetController?
请帮帮我!谢谢
class AlphabetController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {
var collectionView: UICollectionView!
let alphabet = ["A", "Ă", "Â", "B", "C", "D", "Đ", "E", "Ê", "G", "H", "I", "K", "M", "N", "O", "Ô", "Ơ", "P", "Q", "R", "S", "T", "U", "Ư", "V", "X", "Y"]
var audioPlayer: AVAudioPlayer?
override func viewDidLoad() {
super.viewDidLoad()
}
我试过了
extension AlphabetController {
static var storyboardIdentifier: String {
return String(describing: self)
}
答:
评论
AlphabetController