스토리보드 때문에 생기는 문제였다.
현재 이전 코드를 조금 더 예뻐 보이게 바꾸는 중인데 ^__^ ,, SceneDelegate에서 앱을 실행 시 처음에 Storyboard와 연결해서 실행하드라.
if UserDefaultsHelper.shared.haveBeenBefore {
// 처음이 아닐 때
let sb = UIStoryboard(name: "Main", bundle: nil)
guard let tabBarController = sb.instantiateViewController(withIdentifier: "mainTabBarController") as? UITabBarController else {
fatalError("탭바 컨트롤러를 가져올 수 없습니다.")
}
let firstNav = UINavigationController(rootViewController: TrendViewController())
firstNav.tabBarItem = UITabBarItem(title: "Today's Trend", image: UIImage(systemName: "sparkles.tv.fill"), selectedImage: UIImage(systemName: "sparkles.tv.fill"))
guard let secondVC = sb.instantiateViewController(withIdentifier: RecommendationViewController.identifier) as? RecommendationViewController else { return }
let secondNav = UINavigationController(rootViewController: secondVC)
secondNav.tabBarItem = UITabBarItem(title: "Recommendation", image: UIImage(systemName: "magnifyingglass.circle.fill"), selectedImage: UIImage(systemName: "magnifyingglass.circle.fill"))
guard let thirdVC = sb.instantiateViewController(withIdentifier: TheaterViewController.identifier) as? TheaterViewController else { return }
let thirdNav = UINavigationController(rootViewController: thirdVC)
let fourthVC = ProfileViewController()
let fourthNav = UINavigationController(rootViewController: fourthVC)
fourthNav.tabBarItem = UITabBarItem(title: "Profile", image: UIImage(systemName: "person.crop.circle.fill"), selectedImage: UIImage(systemName: "person.crop.circle.fill"))
tabBarController.viewControllers = [firstNav, secondNav, thirdNav, fourthNav]
window?.rootViewController = tabBarController
window?.makeKeyAndVisible()
}
해당하는 스토리보드를 지우고 스토리보드와 이어지는 코드를 바꿔서 해결했다!
이전에 스토리보드 베이스의 코드를 코드베이스로 리팩토링했었기 땜에 ,, ^__^
일부 코드는 스토리보드고 또 일부는 코드베이스로 되어 있다.
이번에 본 오류는 난생 첨 보는 거라 엥? 했는데 구글링하니 생각보다 빨리 해결했다
무조건 스토리보드와 연결하는 코드를 썼을 때, 스토리보드에서 등록했던 뷰컨트롤러와 제대로 연결되지 않아 생기는 오류 같으니 스토리보드와 해당 스토리보드와 연결된 코드를 보면 쉽게 해결할 수 있을 것이다.
'iOS > Error' 카테고리의 다른 글
.app has comflicting provisioning settings. (0) | 2024.03.20 |
---|---|
[Error] Layout은 기깔나게 잡았는데 이미지가 자꾸 튀어나와요 (0) | 2023.12.14 |
[Error] The resource could not be loaded because the App Transport Security policy requires the use of a secure connection. (2) | 2023.11.17 |
[Error] Multiple commands produce Error (0) | 2023.10.07 |
[Error] Escaping closure captures 'inout' parameter 'list' (0) | 2023.08.13 |