ログイン画面のログインボタンの後ろに画像を追加します。ここでは...FirebaseAuthUI IOS - ログイン画面の背景イメージを追加する方法は?
をNSBundle < ...>名前とされ
がキャッチされない例外により「NSInternalInconsistencyException」にアプリを終了、理由:::「バンドル内NIBをロードできませんでした。」私は現在、次のエラーメッセージが表示されます私のコード:AppDelegateで
:CustomAuthViewControllerで
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
var authHandle: AuthStateDidChangeListenerHandle?
var userInfo:User!
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
//checkLoggedIn
authHandle = Auth.auth().addStateDidChangeListener { auth, user in
if let user = user {
self.userInfo = user
} else {
// No user is signed in.
self.login()
}
}
return true
}
func login() {
let authUI = FUIAuth.defaultAuthUI()
authUI?.delegate = self as? FUIAuthDelegate
let providers: [FUIAuthProvider] = [
FUIFacebookAuth()
]
authUI?.providers = providers
// Present the auth view controller and then implement the sign in callback.
let authViewController = CustomAuthViewController(authUI: authUI!)
self.window?.rootViewController?.present(authViewController, animated: false, completion: nil)
}
func authPickerViewController(for authUI: FUIAuth) -> FUIAuthPickerViewController {
return CustomAuthViewController(nibName: "CustomAuthViewController",
bundle: Bundle.main,
authUI: authUI)
}
}
:
class CustomAuthViewController: FUIAuthPickerViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
let width = UIScreen.main.bounds.size.width
let height = UIScreen.main.bounds.size.height
let imageViewBackground = UIImageView(frame: CGRect(x: 0, y: 0, width: width, height: height))
imageViewBackground.image = UIImage(named: "myimage")
// you can change the content mode:
imageViewBackground.contentMode = UIViewContentMode.scaleToFill
view.insertSubview(imageViewBackground, at: 0)
}
何が間違っていますか? authPickerViewController関数が私のAppDelegateになければならないかどうかはわかりませんが、確認できますか?
私はthisポストとthis oneを見つけましたが、動作させることはできません。 私はFirebase-UI 4.1.1を使用しています。私のログインフローは、バックグラウンドイメージなしで動作します(CustomPickerViewControllerを使用しない場合)。
import UIKit
import FirebaseAuthUI
class BizzyAuthViewController: 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()
// Do any additional setup after loading the view.
let width = UIScreen.main.bounds.size.width
let height = UIScreen.main.bounds.size.height
let imageViewBackground = UIImageView(frame: CGRect(x: 0, y: 0, width: width, height: height))
imageViewBackground.image = UIImage(named: "lavenderWithBees")
// you can change the content mode:
imageViewBackground.contentMode = UIViewContentMode.scaleAspectFill
view.insertSubview(imageViewBackground, at: 0)
}
}
そして、これが( "ViewController.swift" 内の)私のログイン機能がどのように見えるかです::
は、これは私のカスタマイズされたオーバーライドがどのように見えるかで、
アレックス
この[回答](https://stackoverflow.com/a/13931118/4056108) – chirag90
またはこの[answer](https://stackoverflow.com/a/28037785/4056108) – chirag90
これらのリンクありがとうございます! FirebaseAuthUiに関連しているので、私は自分の問題を解決する方法を知りません。だから私はログインのための私のストーリーボードにコントローラを持っていない、それは処理され、Firebaseによって読み込まれます。 authViewController = CustomAuthViewController(authUI:authUI!)を、AppDelegateのauthViewController = authUI!.authViewController()で置き換えると、ログインフローは機能しますが、背景イメージはありません。プロジェクトのクリーニングは機能しません。 – Alex9494