使用情节提要板时出现带SceneDelegate的黑屏

时间:2020-06-13 01:19:54

标签: ios swift xcode uiscenedelegate

首先显示AuthViewController(又名root) 然后是带有tabBarController的黑屏,但上面没有项目。

可能是什么问题?

$url = $this->url;
$filename = $_FILES['logo']['name'];
$filedata = $_FILES['logo']['tmp_name'];
$filesize = $_FILES['logo']['size'];

if ($filedata != '') {
    echo $filename;
    $headers = array("Content-Type:multipart/form-data"); // cURL headers for file uploading
    $postfields = array("filedata" => "@$filedata", "filename" => $filename);
    $ch = curl_init();
    $options = array(
        CURLOPT_URL => $url,
        CURLOPT_HEADER => true,
        CURLOPT_POST => 1,
        CURLOPT_HTTPHEADER => $headers,
        CURLOPT_POSTFIELDS => $postfields,
        CURLOPT_INFILESIZE => $filesize,
        CURLOPT_RETURNTRANSFER => true
    ); // cURL options
    curl_setopt_array($ch, $options);
    curl_exec($ch);
    if(!curl_errno($ch)) {
        $info = curl_getinfo($ch);
        if ($info['http_code'] == 200)
            $errmsg = "File uploaded successfully";
    }
    else {
        $errmsg = curl_error($ch);
    }
    curl_close($ch);
}

1 个答案:

答案 0 :(得分:0)

编辑:由于您正在使用情节提要,因此需要从情节提要实例化。 您需要使用windowScene初始化窗口变量window。

var window: UIWindow?

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

        guard let windowScene = (scene as? UIWindowScene) else { return }

        window = UIWindow(windowScene: windowScene)
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        if let user = Auth.auth().currentUser {
            FirestoreServices.shared.getUserData(user: user) { (result) in
                switch result {
                case .success(let muser):
                    let mainTabBar = storyboard.instantiateViewController(withIdentifier: "viewControllerIDInStoryboard") as! TabViewController
                    mainTabBar.currentUser = muser
                    mainTabBar.modalPresentationStyle = .fullScreen
                    self.window?.rootViewController = mainTabBar
                    print("BLA BLA \(String(describing: self.window?.frame))")
                case .failure(_):
                    let authVC = storyboard.instantiateViewController(withIdentifier: "viewControllerIDInStoryboard") as! AuthViewController
                    self.window?.rootViewController = authVC
                }
            }
        } else {
            let authVC = storyboard.instantiateViewController(withIdentifier: "viewControllerIDInStoryboard") as! AuthViewController
            self.window?.rootViewController = authVC
        }
        window?.makeKeyAndVisible()
    }