- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试自定义 FUIAuthPickerViewController
以便我可以使用 FirebaseUI 身份验证将自定义身份验证屏幕作为我的登录屏幕
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'
我知道有一个错误阻止 FUIAuthPickerViewController
成为 Root View Controller ,所以在 Main.Storyboard
中我添加了一个空白 View Controller 并设置了类成为我的 CustomLoginViewController
子类 FUIAuthPickerViewController
想知道是否有人能指出我正确的方向?不知道为什么我会收到该错误。
谢谢
import UIKit
import FirebaseAuth
import FirebaseAuthUI
class CustomLoginViewController: FUIAuthPickerViewController {
override init(nibName: String?, bundle: Bundle?, authUI: FUIAuth) {
super.init(nibName: "FUIAuthPickerViewController", bundle: bundle, authUI: authUI)
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
if !isUserSignedIn() {
showLoginView()
}
}
private func isUserSignedIn() -> Bool {
guard FIRAuth.auth()?.currentUser != nil else { return false }
return true
}
private func showLoginView() {
if let authVC = FUIAuth.defaultAuthUI()?.authViewController() {
present(authVC, animated: true, completion: nil)
}
}
这是我的 AppDelegate.swift
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, FUIAuthDelegate {
var window: UIWindow?
var storyboard: UIStoryboard?
var authUI: FUIAuth?
let providers: [FUIAuthProvider] = [
FUIGoogleAuth(),
FUIFacebookAuth()
]
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
authUI = FUIAuth.defaultAuthUI()
authUI?.delegate = self
authUI?.providers = providers
return true
}
func authUI(_ authUI: FUIAuth, didSignInWith user: FIRUser?, error: Error?) {
print("SIGNED IN")
}
public func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = SDKApplicationDelegate.shared.application(app, open: url, options: options)
return handled || GIDSignIn.sharedInstance().handle(url, sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String, annotation: options[UIApplicationOpenURLOptionsKey.annotation])
}
func authPickerViewController(forAuthUI authUI: FUIAuth) -> FUIAuthPickerViewController {
return CustomLoginViewController(authUI: authUI)
}
这是完整的调用栈
*** Terminating app due to uncaught exception 'NSGenericException', reason: 'This coder requires that replaced objects be returned from initWithCoder:'
*** First throw call stack: ( 0 CoreFoundation 0x00000001065c1d4b __exceptionPreprocess + 171 1 libobjc.A.dylib 0x000000010602321e objc_exception_throw + 48 2 CoreFoundation 0x000000010662b2b5 +[NSException raise:format:] + 197 3 UIKit 0x0000000104dda1eb UINibDecoderDecodeObjectForValue + 758 4 UIKit 0x0000000104dd9eee -[UINibDecoder decodeObjectForKey:] + 98 5 UIKit 0x0000000104be5d14 -[UIRuntimeConnection initWithCoder:] + 178 6 UIKit 0x0000000104dda1a1 UINibDecoderDecodeObjectForValue + 684 7 UIKit 0x0000000104dda357 UINibDecoderDecodeObjectForValue + 1122 8 UIKit 0x0000000104dd9eee -[UINibDecoder decodeObjectForKey:] + 98 9 UIKit 0x0000000104be4eb8 -[UINib instantiateWithOwner:options:] + 1249 10 UIKit 0x0000000104fa4f7b -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181 11 UIKit 0x00000001047d747d -[UIApplication
_loadMainStoryboardFileNamed:bundle:] + 111 12 UIKit 0x00000001047d7947 -[UIApplication _loadMainInterfaceFile] + 260 13 UIKit 0x00000001047d5fa8 -[UIApplication
_runWithMainScene:transitionContext:completion:] + 1406 14 UIKit 0x00000001047d326d -[UIApplication workspaceDidEndTransaction:] + 188 15 FrontBoardServices 0x000000010925a6cb
__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 24 16 FrontBoardServices 0x000000010925a544
-[FBSSerialQueue _performNext] + 189 17 FrontBoardServices 0x000000010925a8cd -[FBSSerialQueue _performNextFromRunLoopSource] + 45 18 CoreFoundation 0x0000000106566761
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17 19 CoreFoundation 0x000000010654b98c
__CFRunLoopDoSources0 + 556 20 CoreFoundation 0x000000010654ae76 __CFRunLoopRun + 918 21 CoreFoundation 0x000000010654a884 CFRunLoopRunSpecific + 420 22 UIKit 0x00000001047d1aea -[UIApplication _run] + 434 23 UIKit 0x00000001047d7c68 UIApplicationMain + 159 24 Surfshop 0x0000000100f54cbf main + 111 25 libdyld.dylib 0x00000001073e968d start + 1 26 ??? 0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with uncaught exception of type NSException
最佳答案
通过创建一个名为 MyViewController 的 UIViewController 的新子类并将 Storyboard 中的类属性设置为 MyViewController 而不是 CustomLoginViewController 解决了这个问题
关于ios - 尝试自定义 FUIAuthPickerViewController 并在 AppDelegate 中出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42017388/
如何使用自定义按钮、自定义操作、背景、加载器等自定义 Firebase UI Auth Picker Controller 。 我已经尝试子类化 FUIAuthPickerViewController
因此,我出于自定义目的对 FUIAuthPickerViewController 进行了子类化,但无法显示背景。将 Firebase Pod 更新到最新版本后开始发生这种情况(在之前的版本上运行良好)
我正在尝试自定义 FUIAuthPickerViewController 以便我可以使用 FirebaseUI 身份验证将自定义身份验证屏幕作为我的登录屏幕 *** Terminating app d
我能在网上找到的唯一相关问题是 GitHub 上的问题报告: https://github.com/firebase/FirebaseUI-iOS/issues/128 然而,似乎没有任何解决办法。
我是一名优秀的程序员,十分优秀!