我是编程新手,现在正在尝试做一个应用程序。当我尝试制作Google登录按钮时,问题就开始了,当我认为我已经做到了这一点时,我尝试了模拟器,单击它们时我的按钮都不起作用,甚至文本方块都没有。然后模拟器开始崩溃,代码线程 1:SIGABRT。我在某个地方读到你可以做一个 exeption 断点来查看问题所在,当我这样做时,我来到了一些行,其中一行说线程 1:断点 3.1。
import UIKit
import Google
class ViewController: UIViewController, GIDSignInUIDelegate {
override func viewDidLoad() {
super.viewDidLoad()
GIDSignIn.sharedInstance().uiDelegate = self
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBOutlet weak var signinbutton3: GIDSignInButton!
@IBOutlet weak var signinbutton: GIDSignInButton!
func signInWillDispatch(signIn: GIDSignIn!, error: NSError!) {
}
// Present a view that prompts the user to sign in with Google
func signIn(signIn: GIDSignIn!,
presentViewController viewController: UIViewController!) {
self.present(viewController, animated: true, completion: nil)
print("Sign in presented")
}
// Dismiss the "Sign in with Google" view
func signIn(signIn: GIDSignIn!,
dismissViewController viewController: UIViewController!) {
self.dismiss(animated: true, completion: nil)
print("Sign in dismissed")
}
override func viewDidAppear(_ animated: Bool) {
self.performSegue(withIdentifier: "loginView", sender: self); //this line is where the Thread 1: Breakpoint 3.1 was.
}
}
我的问题很快:
- 模拟器上的按钮不起作用
- 模拟器崩溃并在 xcode 上显示我之前显示的代码序列,最后一行中说线程 1:SIGABRT 和线程 1:断点 3.1。
您认为问题是什么,我应该如何解决?编辑我在尝试启动模拟器时收到此消息:
objc[22047]:类 PLBuildVersion 在两者中实现/Applications/Xcode.app/Content/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x113a45cc0)和/Applications/Xcode.app/Content/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x11385c6f0).将使用两者之一。哪一个是未定义的。 2017-06-13 21:49:25.051 Startifyapp[22047] [火力基地/核心][I-COR000003]默认的 Firebase 应用尚未 配置。将 [FIRApp 配置] 添加到应用程序初始化中。 2017-06-13 21:49:26.013 Startifyapp[22047:788392]* 终止应用 由于未捕获的异常"NSInvalidArgumentException",原因: '接收器 () 没有 segue 标识符为"登录视图" *第一个抛出调用堆栈:( 0 CoreFoundation 0x000000010bf6eb0b例外预处理 + 171 1 libobjc。A.dylib
0x000000010d2ab141 objc_exception_throw + 48 2 UIKit
0x000000010e00bef3 -[UIViewController shouldPerformSegueWithIdentifier:sender:] + 0 3 Startifyapp
0x000000010b971fbfTFC11Startifyapp14ViewController13viewDidAppearfSbT+ 127 4 Startifyapp 0x000000010b972021TToFC11Startifyapp14ViewController13viewDidAppearfSbT+ 49 5 UIKit 0x000000010e00ecae -[UIViewController _setViewAppearState:isAnimating:] + 704 6 UIKit 0x000000010e00f6d4 -[UIViewController _endAppearanceTransition:] + 197 7 UIKit 0x000000010dfe1f94 -[UIPresentationController transitionDidFinish:] + 868 8 UIKit 0x000000010e1f6525 -[_UICurrentContextPresentationController transitionDidFinish:] + 44 9 UIKit
0x000000010dfe5af6 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke_2 + 183 10 UIKit
0x000000010e995d1c -[_UIViewControllerTransitionContext completeTransition:] + 102 11 UIKit
0x000000010dfdeec0 -[UITransitionView notifyDidCompleteTransition:] + 251 12 UIKit 0x000000010dfdeb38 -[UITransitionView _didCompleteTransition:] + 1408 13 UIKit 0x000000010dfe1208 -[UITransitionView _transitionDidStop:done:] + 104 14 UIKit 0x000000010def2257 -[UIViewAnimationState sendDelegateAnimationDidStop:finish:] + 222 15 UIKit 0x000000010def2796 -[UIView动画状态动画DidStop:已完成:] + 136 16 石英核心0x00000001151a968e _ZN2CA5Layer23run_animation_callbacksEPv + 306 17 libdispatch.dylib 0x00000001100f305c _dispatch_client_callout + 8 18 libdispatch.dylib 0x00000001100d440b _dispatch_main_queue_callback_4CF + 411 19 核心基金会0x000000010bf33909 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE+ 9 20 核心基金会 0x000000010bef9ae4 __CFRunLoopRun + 2164 21 CoreFoundation 0x000000010bef9016 CFRunLoopRunspecific + 406 22 GraphicsServices
0x0000000111775a24 GSEventRunModal + 62 23 UIKit
0x000000010de66134 UIApplicationMain + 159 24 Startifyapp
0x000000010b9700d7 main + 55 25 libdyld.dylib
0x000000011013f65d start + 1 26 ???
0x0000000000000001 0x0 + 1 ) libc++abi.dylib:结尾为 NSException (lldb) 类型的未捕获异常
我在Xcode 9和模拟器上遇到了同样的问题。 我在iOS 11中使用了真实设备,它运行良好(尽管有一些错误)