PageViewController ์ด์
PageViewController๋ฅผ ์ฒ์ ์ฌ์ฉํ๋ค๋ณด๋ฉด ๋ค์๊ณผ ๊ฐ์ ์ด์๋ฅผ ๋ง๋ ์ ์๋ค.
ํด์์ ์กฐ๊ธ๋ง ํด๋ณด๋ฉด ์ฝ๊ฒ ๋ฌธ์ ๋ฅผ ์ ์ ์๋ค.
Issue
Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'The number of view controllers provided (3) doesn't match
the number required (1) for the requested transition'
View Controller๊ฐ ํ์ ์ด์์ผ๋ก ํ ๋น๋์๋ค๋ ๊ฒ์ด๋ค.
1๊ฐ๋ง ํ์ํ๋ฐ 3๊ฐ๋ ๋ฃ์๋ค๋ ๊ฒ์ด๋ค. ๐
๊ธฐ์กด ์ฝ๋
// PageViewController.swift
import UIKit
class PageViewController: UIPageViewController {
override func viewDidLoad() {
super.viewDidLoad()
let firstVC = FirstViewController()
let secondVC = SecondViewController()
let thirdVC = ThirdViewController()
setViewControllers([firstVC, secondVC, thirdVC], direction: .forward, animated: true, completion: nil)
}
}
์์ ์ฝ๋
// PageViewController.swift
import UIKit
class PageViewController: UIPageViewController {
override func viewDidLoad() {
super.viewDidLoad()
let firstVC = FirstViewController()
let secondVC = SecondViewController()
let thirdVC = ThirdViewController()
// โ
์์ ๋ถ๋ถ : ์ธ์๋ก View Controller ํ๋๋ง ์ ๋ฌ
setViewControllers([firstVC], direction: .forward, animated: true, completion: nil)
}
}
'๐ iOS & Swift' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[iOS] overriding non-open instance method outside of its defining module (0) | 2022.08.22 |
---|---|
Notification, ์ฝ๋๋ฅผ ๊ฐ์ ํด๋ณด์ (0) | 2022.08.21 |
[iOS] Type 'object' does not conform to protocol 'Decodableโ / โEncodableโ (0) | 2022.08.20 |
first(where:)์ first (0) | 2022.08.20 |
๋น๋๊ธฐ ํ๋ก๊ทธ๋๋ฐ์ด๋? (0) | 2022.08.20 |