2. 打開 XCode 和 專案
3. 在appDelegate加入
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.z
#if DEBUG
#if targetEnvironment(simulator)
#if os(iOS)
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/iOSInjection.bundle")?.load()
#elseif os(tvOS)
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/tvOSInjection.bundle")?.load()
#endif
#elseif os(macOS)
Bundle(path: "/Applications/InjectionIII.app/Contents/Resources/macOSInjection.bundle")?.load()
#endif
#endif
return true
}
PS.
已經秀出來的view並未改變。但是,新present出的view確實已經改變
如需要改變已秀出來的view,需在每個controller上實作
@objc func injected() {
// 可馬上更新的code
}
建議的懶人法
@objc func injected() {
// 移除全部vc/view
if self.childViewControllers.count > 0{
let viewControllers:[UIViewController] = self.childViewControllers
for viewContoller in viewControllers{
viewContoller.willMove(toParentViewController: nil)
viewContoller.view.removeFromSuperview()
viewContoller.removeFromParentViewController()
}
}
configureView()
}
func configureView() {
}
override func viewDidLoad() {
super.viewDidLoad()
configureView()
}