草庐IT

swift - 无法识别的选择器发送到实例 0x7f9d19e02870 ISSUE with UIButton

coder 2023-09-11 原文

当我单击按钮 creaX 时,我的应用程序崩溃并且控制台显示以下错误,Thread 1: signal SIGABRT in AppDelegate .我试图检查按钮是否有它可能没有的 socket ,但一切正常,我试图断开按钮与 ViewController 的连接并重新连接它,我试图再创建一次 Action 按钮(也从 outlets 和 View Controller 中删除了前一个按钮)但错误仍然存​​在:

    2018-07-20 14:33:35.291935+0200 Friendx[8583:238797] 5.4.0 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.50001000 started
2018-07-20 14:33:35.292373+0200 Friendx[8583:238797] 5.4.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2018-07-20 14:33:35.491992+0200 Friendx[8583:238287] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
(
    "<NSLayoutConstraint:0x60c00008d480 UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide'.trailing == UIImageView:0x7f9d19e0ad60.trailing + 92   (active)>",
    "<NSLayoutConstraint:0x60c00008d7a0 UIImageView:0x7f9d19e0ad60.leading == UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide'.leading + 91   (active)>",
    "<NSLayoutConstraint:0x60c00008d7f0 UIImageView:0x7f9d19e0ad60.centerX == UIView:0x7f9d19c0e900.centerX   (active)>",
    "<NSLayoutConstraint:0x60c00008d5c0 'UIViewSafeAreaLayoutGuide-left' H:|-(0)-[UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide'](LTR)   (active, names: '|':UIView:0x7f9d19c0e900 )>",
    "<NSLayoutConstraint:0x60c00008d6b0 'UIViewSafeAreaLayoutGuide-right' H:[UILayoutGuide:0x60c0001bef40'UIViewSafeAreaLayoutGuide']-(0)-|(LTR)   (active, names: '|':UIView:0x7f9d19c0e900 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x60c00008d7f0 UIImageView:0x7f9d19e0ad60.centerX == UIView:0x7f9d19c0e900.centerX   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.
2018-07-20 14:33:35.709930+0200 Friendx[8583:238838] TIC Read Status [1:0x0]: 1:57
2018-07-20 14:33:35.710265+0200 Friendx[8583:238838] TIC Read Status [1:0x0]: 1:57
2018-07-20 14:33:36.665526+0200 Friendx[8583:238799] TIC Read Status [2:0x0]: 1:57
2018-07-20 14:33:36.665640+0200 Friendx[8583:238799] TIC Read Status [2:0x0]: 1:57
L'utente è entrato in Google
L'utente è entrato in Firebase
2018-07-20 14:33:37.075278+0200 Friendx[8583:238799] TIC Read Status [3:0x0]: 1:57
2018-07-20 14:33:37.075677+0200 Friendx[8583:238799] TIC Read Status [3:0x0]: 1:57
2018-07-20 14:33:37.555321+0200 Friendx[8583:238880] TIC Read Status [4:0x0]: 1:57
2018-07-20 14:33:37.555642+0200 Friendx[8583:238880] TIC Read Status [4:0x0]: 1:57
2018-07-20 14:33:38.001073+0200 Friendx[8583:238797] TIC Read Status [5:0x0]: 1:57
2018-07-20 14:33:38.001287+0200 Friendx[8583:238797] TIC Read Status [5:0x0]: 1:57
2018-07-20 14:33:38.087722+0200 Friendx[8583:238287] Failed to set (coloreBordiStackView) user defined inspected property on (UIStackView): [<UIStackView 0x7f9d1c128960> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key coloreBordiStackView.
2018-07-20 14:33:38.087990+0200 Friendx[8583:238287] Failed to set (BorderWidth) user defined inspected property on (UIStackView): [<UIStackView 0x7f9d1c128960> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key BorderWidth.
2018-07-20 14:33:38.112372+0200 Friendx[8583:238287] [MC] Lazy loading NSBundle MobileCoreServices.framework
2018-07-20 14:33:38.113527+0200 Friendx[8583:238287] [MC] Loaded MobileCoreServices.framework
2018-07-20 14:33:41.023334+0200 Friendx[8583:238287] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /Users/ManuelSchiavon/Library/Developer/CoreSimulator/Devices/656ECD9D-5F69-49E0-A195-E91AC8494850/data/Containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2018-07-20 14:33:41.030739+0200 Friendx[8583:238287] [MC] Reading from private effective user settings.
2018-07-20 14:33:50.357960+0200 Friendx[8583:238287] -[Friendx.ViewController Create:]: unrecognized selector sent to instance 0x7f9d19e02870
2018-07-20 14:33:50.383496+0200 Friendx[8583:238287] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[Friendx.ViewController Create:]: unrecognized selector sent to instance 0x7f9d19e02870'
*** First throw call stack:
(
    0   CoreFoundation                      0x0000000104f2d12b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x00000001045c1f41 objc_exception_throw + 48
    2   CoreFoundation                      0x0000000104fae024 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
    3   UIKit                               0x0000000105cf1f51 -[UIResponder doesNotRecognizeSelector:] + 295
    4   CoreFoundation                      0x0000000104eaff78 ___forwarding___ + 1432
    5   CoreFoundation                      0x0000000104eaf958 _CF_forwarding_prep_0 + 120
    6   UIKit                               0x0000000105abf972 -[UIApplication sendAction:to:from:forEvent:] + 83
    7   UIKit                               0x0000000105c3ec3c -[UIControl sendAction:to:forEvent:] + 67
    8   UIKit                               0x0000000105c3ef59 -[UIControl _sendActionsForEvents:withEvent:] + 450
    9   UIKit                               0x0000000105c3de86 -[UIControl touchesEnded:withEvent:] + 618
    10  UIKit                               0x0000000105b35807 -[UIWindow _sendTouchesForEvent:] + 2807
    11  UIKit                               0x0000000105b36f2a -[UIWindow sendEvent:] + 4124
    12  UIKit                               0x0000000105ada365 -[UIApplication sendEvent:] + 352
    13  UIKit                               0x0000000106426a1d __dispatchPreprocessedEventFromEventQueue + 2809
    14  UIKit                               0x0000000106429672 __handleEventQueueInternal + 5957
    15  CoreFoundation                      0x0000000104ed0101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
    16  CoreFoundation                      0x0000000104f6ff71 __CFRunLoopDoSource0 + 81
    17  CoreFoundation                      0x0000000104eb4a19 __CFRunLoopDoSources0 + 185
    18  CoreFoundation                      0x0000000104eb3fff __CFRunLoopRun + 1279
    19  CoreFoundation                      0x0000000104eb3889 CFRunLoopRunSpecific + 409
    20  GraphicsServices                    0x0000000109c159c6 GSEventRunModal + 62
    21  UIKit                               0x0000000105abe5d6 UIApplicationMain + 159
    22  Friendx                             0x0000000102164cd7 main + 55
    23  libdyld.dylib                       0x00000001088f9d81 start + 1
    24  ???                                 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

ViewController.swift (UIBUTTON Action )

@IBAction func Create(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!)
    {
        let userID: String = user.userID
        let nomegruppo = TF_nomegruppo.text
        let membro1 = TF_membro1.text

        if TF_membro1.text == Auth.auth().currentUser?.email {
            self.TF_membro1?.text = "Immetti un' altra email"
            self.BT_creaX?.isEnabled = false

        } else {
            self.BT_creaX?.isEnabled = true
        }

        if (TF_membro1.text != nil) && TF_nomegruppo.text != "" {
            self.BT_creaX?.isEnabled = true
            Database.database().reference().child("Users").child(userID).child("Groups").child(nomegruppo!).setValue(["membro1": TF_membro1])
        } else {
            self.BT_creaX?.isEnabled = false
        }
    }

应用委托(delegate):

import UIKit
import Firebase
import GoogleSignIn

@UIApplicationMain

class AppDelegate: UIResponder, UIApplicationDelegate, GIDSignInDelegate {

    var window: UIWindow?



    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        FirebaseApp.configure()

        GIDSignIn.sharedInstance().clientID = FirebaseApp.app()?.options.clientID
        GIDSignIn.sharedInstance().delegate = self

        return true
    }

    func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool {

    return GIDSignIn.sharedInstance().handle(url,
                                             sourceApplication: options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String,
                                             annotation: options[UIApplicationOpenURLOptionsKey.annotation])

    }
    func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
        return GIDSignIn.sharedInstance().handle(url,
                                                 sourceApplication: sourceApplication,
                                                 annotation: annotation)

    }
    func sign(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!, withError error: Error?) {
        // ...
        if error != nil {
            // ...
            return
        }
        print("L'utente è entrato in Google")

        guard let authentication = user.authentication else { return }
        let credential = GoogleAuthProvider.credential(withIDToken: authentication.idToken,
                                                       accessToken: authentication.accessToken
                                                                  )

        // ...
        Auth.auth().signInAndRetrieveData(with: credential) { (authResult, error) in
            if error != nil {
                // ...
                return
            }
            // User is signed in
            // ...
            let userID: String = user.userID
            let userName: String = user.profile.name
            let userEmail: String = user.profile.email
            let userImage = user.profile.imageURL(withDimension: 400).absoluteString  /// url of image square of 400 * 400



            Database.database().reference().child("Users").child(userID).setValue(["Name": userName,"Email": userEmail,"Image": userImage])//Salva il nomeuserName e l'url dell'immagine profilo in Firebase
            self.window?.rootViewController?.performSegue(withIdentifier: "HomeSegue", sender: self) //Per andare al secondo screen, "HomeSegue è il nome del collegamento tra il UIViewController 1 e 2.

                if error != nil {
                    print(error as Any)
                    return



                }
                                }





        print ("L'utente è entrato in Firebase")


    } 

    func sign(_ signIn: GIDSignIn!, didDisconnectWith user: GIDGoogleUser!, withError error: Error!) {
        // Perform any operations when the user disconnects from app here.
        // ...
    }


    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.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }

}

出了什么问题?

最佳答案

这个签名是错误的(好像是你把action连接到按钮上后修改了参数)

@IBAction func Create(_ signIn: GIDSignIn!, didSignInFor user: GIDGoogleUser!)

应该是

@IBAction func Create(_ sender: UIButton)

此外,您希望按钮从哪里为您提供 GIDSignIn 的值 && GIDGoogleUser ,它只能提供自己 并重新评估您与他们分享的值(value)观

关于swift - 无法识别的选择器发送到实例 0x7f9d19e02870 ISSUE with UIButton,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51442986/

有关swift - 无法识别的选择器发送到实例 0x7f9d19e02870 ISSUE with UIButton的更多相关文章

  1. ruby-on-rails - 如何使用 instance_variable_set 正确设置实例变量? - 2

    我正在查看instance_variable_set的文档并看到给出的示例代码是这样做的:obj.instance_variable_set(:@instnc_var,"valuefortheinstancevariable")然后允许您在类的任何实例方法中以@instnc_var的形式访问该变量。我想知道为什么在@instnc_var之前需要一个冒号:。冒号有什么作用? 最佳答案 我的第一直觉是告诉你不要使用instance_variable_set除非你真的知道你用它做什么。它本质上是一种元编程工具或绕过实例变量可见性的黑客攻击

  2. ruby 正则表达式 - 如何替换字符串中匹配项的第 n 个实例 - 2

    在我的应用程序中,我需要能够找到所有数字子字符串,然后扫描每个子字符串,找到第一个匹配范围(例如5到15之间)的子字符串,并将该实例替换为另一个字符串“X”。我的测试字符串s="1foo100bar10gee1"我的初始模式是1个或多个数字的任何字符串,例如,re=Regexp.new(/\d+/)matches=s.scan(re)给出["1","100","10","1"]如果我想用“X”替换第N个匹配项,并且只替换第N个匹配项,我该怎么做?例如,如果我想替换第三个匹配项“10”(匹配项[2]),我不能只说s[matches[2]]="X"因为它做了两次替换“1fooX0barXg

  3. ruby-on-rails - 如果 Object::try 被发送到一个 nil 对象,为什么它会起作用? - 2

    如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象

  4. ruby-on-rails - Rails - 从另一个模型中创建一个模型的实例 - 2

    我有一个正在构建的应用程序,我需要一个模型来创建另一个模型的实例。我希望每辆车都有4个轮胎。汽车模型classCar轮胎模型classTire但是,在make_tires内部有一个错误,如果我为Tire尝试它,则没有用于创建或新建的activerecord方法。当我检查轮胎时,它没有这些方法。我该如何补救?错误是这样的:未定义的方法'create'forActiveRecord::AttributeMethods::Serialization::Tire::Module我测试了两个环境:测试和开发,它们都因相同的错误而失败。 最佳答案

  5. ruby-on-rails - RSpec:避免使用允许接收的任何实例 - 2

    我正在处理旧代码的一部分。beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)endRubocop错误如下:Avoidstubbingusing'allow_any_instance_of'我读到了RuboCop::RSpec:AnyInstance我试着像下面那样改变它。由此beforedoallow_any_instance_of(SportRateManager).toreceive(:create).and_return(true)end对此:let(:sport_

  6. ruby-on-rails - 使用 ruby​​ 将多个实例变量转换为散列的更好方法? - 2

    我收到格式为的回复#我需要将其转换为哈希值(针对活跃商家)。目前我正在遍历变量并执行此操作:response.instance_variables.eachdo|r|my_hash.merge!(r.to_s.delete("@").intern=>response.instance_eval(r.to_s.delete("@")))end这有效,它将生成{:first="charlie",:last=>"kelly"},但它似乎有点hacky和不稳定。有更好的方法吗?编辑:我刚刚意识到我可以使用instance_variable_get作为该等式的第二部分,但这仍然是主要问题。

  7. ruby - Rails 3 的 RGB 颜色选择器 - 2

    状态:我正在构建一个应用程序,其中需要一个可供用户选择颜色的字段,该字段将包含RGB颜色代码字符串。我已经测试了一个看起来很漂亮但效果不佳的。它是“挑剔的颜色”,并托管在此存储库中:https://github.com/Astorsoft/picky-color.在这里我打开一个关于它的一些问题的问题。问题:请建议我在Rails3应用程序中使用一些颜色选择器。 最佳答案 也许页面上的列表jQueryUIDevelopment:ColorPicker为您提供开箱即用的产品。原因是jQuery现在包含在Rails3应用程序中,因此使用基

  8. 报告回顾丨模型进化狂飙,DetectGPT能否识别最新模型生成结果? - 2

    导读语言模型给我们的生产生活带来了极大便利,但同时不少人也利用他们从事作弊工作。如何规避这些难辨真伪的文字所产生的负面影响也成为一大难题。在3月9日智源Live第33期活动「DetectGPT:判断文本是否为机器生成的工具」中,主讲人Eric为我们讲解了DetectGPT工作背后的思路——一种基于概率曲率检测的用于检测模型生成文本的工具,它可以帮助我们更好地分辨文章的来源和可信度,对保护信息真实、防止欺诈等方面具有重要意义。本次报告主要围绕其功能,实现和效果等展开。(文末点击“阅读原文”,查看活动回放。)Ericmitchell斯坦福大学计算机系四年级博士生,由ChelseaFinn和Chri

  9. [Vuforia]二.3D物体识别 - 2

    之前说过10之后的版本没有3dScan了,所以还是9.8的版本或者之前更早的版本。 3d物体扫描需要先下载扫描的APK进行扫面。首先要在手机上装一个扫描程序,扫描现实中的三维物体,然后上传高通官网,在下载成UnityPackage类型让Unity能够使用这个扫描程序可以从高通官网上进行下载,是一个安卓程序。点到Tools往下滑,找到VuforiaObjectScanner下载后解压数据线连接手机,将apk文件拷入手机安装然后刚才解压文件中的Media文件夹打开,两个PDF图打印第一张A4-ObjectScanningTarget.pdf,主要是用来辅助扫描的。好了,接下来就是扫描三维物体。将瓶

  10. ruby-on-rails - 在 heroku 的 .fonts 文件夹中包含自定义字体,似乎无法识别它们 - 2

    Heroku支持人员告诉我,为了在我的Web应用程序中使用自定义字体(未安装在系统中,您可以在bash控制台中使用fc-list查看已安装的字体)我必须部署一个包含所有字体的.fonts文件夹里面的字体。问题是我不知道该怎么做。我的意思是,我不知道文件名是否必须遵循heroku的任何特殊模式,或者我必须在我的代码中做一些事情来考虑这种字体,或者如果我将它包含在文件夹中它是自动的......事实是,我尝试以不同的方式更改字体的文件名,但根本没有使用该字体。为了提供更多详细信息,我们使用字体的过程是将PDF转换为图像,更具体地说,使用rghostgem。并且最终图像根本不使用自定义字体。在

随机推荐