Xcode 11的SWRevealViewController问题

伊芙琳

我已经为SWRevealViewController设置了所有代码,它在Xcode 10.3甚至Xcode 11.2 beta 2上都可以正常工作,但是由于某些原因,它在App Store的最新更新中不起作用,最终在该应用程序中出现此错误代表

线程1:EXC_BAD_ACCESS(代码= 1,地址= 0x48)

我用SWRevealView Controller切换后的屏幕。任何想法我怎么能解决这个问题

对我来说很奇怪,因为之前我从未遇到过SWRevealViewController的问题

这是我在ViewDidLoad上用于所有视图控制器的代码以及我的App Delegate的代码

    menuButton.target = self.revealViewController()
    menuButton.action = #selector(SWRevealViewController.revealToggle(_:))

    self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

import UIKit
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Onboarding
        let launchedBefore = UserDefaults.standard.bool(forKey: "hasLaunched")
        self.window = UIWindow(frame: UIScreen.main.bounds)
        let launchStoryboard = UIStoryboard(name:"Onboarding", bundle: nil)
        let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
        var vc: UIViewController

        if launchedBefore {
            vc = mainStoryboard.instantiateInitialViewController()!
        } else {
            vc = launchStoryboard.instantiateViewController(withIdentifier: "AgeVC")
        }
        UserDefaults.standard.set(true, forKey: "hasLaunched")
        self.window?.rootViewController = vc
        self.window?.makeKeyAndVisible()
        // Onboarding End

        FirebaseApp.configure()

        // Override point for customization after application launch.
        UITabBar.appearance().barTintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        UITabBar.appearance().tintColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
        UITabBar.appearance().unselectedItemTintColor = #colorLiteral(red: 0.2, green: 0.9333333333, blue: 0.4588235294, alpha: 1)

        UINavigationBar.appearance().barTintColor = #colorLiteral(red: 1, green: 1, blue: 1, alpha: 1)
        UINavigationBar.appearance().tintColor = #colorLiteral(red: 0, green: 0, blue: 0, alpha: 1)
        UINavigationBar.appearance().titleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.black]

        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

幻灯片菜单

import UIKit

let kStringTransfer = "StringTransferNotification"

class MenuViewController: UITableViewController {

    @IBOutlet weak var addressLabel: UILabel!
    @IBOutlet weak var addressBtn: UIButton!

    override func viewDidLoad() {
        super.viewDidLoad()

        NotificationCenter.default.addObserver(self, selector: #selector(setString(notify:)), name: NSNotification.Name(rawValue: kStringTransfer), object: nil)

        self.revealViewController().rearViewRevealWidth = self.view.frame.width-100//put the width you need
        self.revealViewController().rearViewRevealOverdraw = 0
    }

    @objc func setString(notify: Notification) {
        //set search bar string to text field
        addressLabel.text = notify.object as? String
    }

    func userDidEnterInformation(info: String) {
        addressLabel.text = info
    }
}

方面,它在崩溃前确实工作了几次

伊芙琳

找到了答案,IT部门只是在代码中缺少一个SceneDelegate类,因此它可以正常工作

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章