gpt4 book ai didi

swift - Xcode 11 的 SWRevealViewController 问题

转载 作者:行者123 更新时间:2023-11-28 07:20:26 28 4
gpt4 key购买 nike

我为 SWRevealViewController 设置了所有代码,它在 Xcode 10.3 甚至 Xcode 11.2 beta 2 上运行得非常好,但由于某种原因它无法在 App Store 的最新更新版本上运行,我最终得到了这个错误,在应用委托(delegate)

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

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

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

这是我在我的 ViewDidLoad 上用于我所有 View Controller 的代码和我的 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
}
}

在它崩溃之前它确实工作了几次

最佳答案

找到了答案,它只是在代码中缺少一个 SceneDelegate 类才能工作,现在它工作顺利

关于swift - Xcode 11 的 SWRevealViewController 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58360824/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com