【问题标题】:xcode iOS App Crashes after the renaming of view controller重命名视图控制器后xcode iOS App崩溃
【发布时间】:2019-08-01 15:17:13
【问题描述】:

OutletsCrash at Entry 崩溃图像截图

重命名 View Controller 后,我遇到了崩溃。 Swift 文件到 CalculatorViewController.swift 我还尝试重构新的类名,以便在应用程序的所有入口端口进行镜像。我收到中止信号错误。请帮忙解决这个问题!这是我的错误 更新:队列 com.apple.mainthread(串行)线程 1 中的错误

代码中的崩溃点

类 AppDelegate: UIResponder, UIApplicationDelegate {

更新。

2019-03-11 15:36:01.990755+0530 NDv2[4619:144763] 未知类 Interface Builder 文件中的 CalculatorViewController。 2019-03-11 15:36:02.040903+0530 NDv2[4619:144763] * 终止应用程序由于 未捕获的异常“NSUnknownKeyException”,原因: '[ setValue:forUndefinedKey:]: 这个 类不符合键 TextOutput 的键值编码。 * 第一次抛出调用堆栈:( 0 CoreFoundation 0x000000010ef3e1bb exceptionPreprocess + 331 1 libobjc.A.dylib
0x000000010cf58735 objc_exception_throw + 48 2 核心基础
0x000000010ef3dd29 -[NSException raise] + 9 3 基础
0x000000010c983de4 -[NSObject(NSKeyValueCoding) setValue:forKey:] + 292 4 UIKitCore 0x00000001113a3292 -[UIViewController setValue:forKey:] + 87 5 UIKitCore 0x000000011163a573 -[UIRuntimeOutletConnection 连接] + 109 6
核心基础 0x000000010ef29cfd -[NSArray makeObjectsPerformSelector:] + 317 7 UIKitCore
0x00000001116372b9 -[UINib instantiateWithOwner:options:] + 1814 8
UIKitCore 0x00000001113aa452 -[UIViewController _loadViewFromNibNamed:bundle:] + 383 9 UIKitCore 0x00000001113aaddc -[UIViewController loadView] + 177 10 UIKitCore
0x00000001113ab0ee-[UIViewController loadViewIfRequired] + 175 11 UIKitCore 0x00000001113ab940 -[UIViewController 视图] + 27 12 UIKitCore 0x0000000111a02c53 -[UIWindow addRootViewControllerViewIfPossible] + 122 13 UIKitCore 0x0000000111a0336e -[UIWindow _setHidden:forced:] + 294 14 UIKitCore 0x0000000111a165c0 -[UIWindow makeKeyAndVisible] + 42 15 UIKitCore
0x00000001119c3833 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4595 16 UIKitCore 0x00000001119c8c2f -[UIApplication_runWithMainScene:transitionContext:completion:] + 1623 17 UIKitCore 0x00000001111e74e9 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 866 18 UIKitCore 0x00000001111f029c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153 19 UIKitCore 0x00000001111e7126 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 233 20 UIKitCore 0x00000001111e7ae0 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1085 21 UIKitCore
0x00000001111e5cb5 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 795 22 UIKitCore 0x00000001111e595f -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 435 23 UIKitCore 0x00000001111eaa90 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 584 24 UIKitCore 0x00000001111eb80e _performActionsWithDelayForTransitionContext + 100 25 UIKitCore 0x00000001111ea7ef -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 221 26 UIKitCore 0x00000001111ef93a -[_UICanvas 场景:didUpdateWithDiff:transitionContext:completion:] + 392 27 UIKitCore 0x00000001119c744e -[UIApplication 工作区:didCreateScene:withTransitionContext:completion:] + 515 28 UIKitCore 0x000000011156bd09 -[UIApplicationSceneClientAgent 场景:didInitializeWithEvent:completion:] + 357 29 FrontBoardServices 0x000000011a0fc2da -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448 30 FrontBoardServices 0x000000011a107443 __56-[FBSWorkspace 客户端:handleCreateScene:withCompletion:]_block_invoke_2 + 271 31 前板服务 0x000000011a106b3a __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53 32 libdispatch.dylib 0x000000011047e602 _dispatch_client_callout + 8 33 libdispatch.dylib 0x0000000110481b78 _dispatch_block_invoke_direct + 301 34 前板服务 0x000000011a13bba8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK
+ 30 35 FrontBoardServices 0x000000011a13b860 -[FBSSerialQueue _performNext] + 457 36 FrontBoardServices 0x000000011a13be40 -[FBSSerialQueue _performNextFromRunLoopSource] + 45 37 核心基础 0x000000010eea3721 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17 38 核心基础 0x000000010eea2f93 __CFRunLoopDoSources0 + 243 39 CoreFoundation 0x000000010ee9d63f __CFRunLoopRun + 1263 40 CoreFoundation
0x000000010ee9ce11 CFRunLoopRunSpecific + 625 41 图形服务
0x000000011713b1dd GSEventRunModal + 62 42 UIKitCore
0x00000001119ca81d UIApplicationMain + 140 43 NDv2
0x000000010c6291c7 主 + 71 44 libdyld.dylib
0x00000001104f4575 start + 1 ) libc++abi.dylib: 终止于 NSException 类型的未捕获异常

【问题讨论】:

  • 您收到此错误是因为您的 viewController 在情节提要中有一个未声明的类。您是否还重命名了情节提要中的课程?
  • 是的,我确实从主故事板中的 ViewController 更改了类!
  • 没有足够的信息附加网点信息顶部

标签: ios swift xcode swift3


【解决方案1】:

ViewController改名有两种方法:

1) 例如:类 LoginViewController:UIViewController - 只需选择“LoginViewController”,然后右键单击 -> 重构 -> 重命名

这将更改名称文件名、类名并照顾故事板类名。

2) 如果你不能使用方法 1,然后手动重命名文件 Name(.swift),那么你必须去 storyboard 并替换视图控制器的类名。您可能对网点有疑问。

3) 之后关闭 Xcode,然后再次启动您的项目。

【讨论】:

  • 确实,我之前做过。我收到一条 SIGABRT 消息,并显示它在 20 Main point 崩溃并在该信号下崩溃
  • 通过清理项目并重建来解决问题。要清理项目,请转到菜单栏:产品 -> 清理然后重建只需像往常一样单击运行按钮
  • 你能告诉我你正在做的确切过程,以便告诉你确切的解决方案。
  • 构建了 View.StoryBoard,然后添加了另一个名为 Model 或 AppEngine.swift 文件的支持文件。那时的工作就像一个魅力,现在只要我将 ViewController 文件更改为 CalculatorVIewController,我就会收到一个错误。即使我反转它也不起作用
  • 您是否也更改了类中的名称:class CalculatorViewController : UIViewController{}
【解决方案2】:

故事板的控制器中有一个 textField 或 textView 或 UILabel,

1- 打开你的故事板

2- 点击 UIViewController(ViewController 的新名字你已经改变了)

3- 删除名称为TextOutput的出口

4- ReConnet 如果你愿意,你准备好了

【讨论】:

  • 对不起,你能改写第二点,点击控制器吗?
  • UIViewController 你改了谁的类名
  • 我更改了 viewcontroller.swift 然后更改了文件名、类名,后来也更改了 Mail.Storyboard 文件。它没有运行。即使我再次将文件反转到 ViewController,它也会崩溃
  • 如果您想解决问题,请按照我所说的尝试或将项目放在网上显示我可以看到它是怎么回事
  • 好的,但是这里怎么做呢?我是这个社区的新手,请多多包涵。
【解决方案3】:

您遇到的错误是因为您的故事板上有一个 IBOutlet,但在定义它的类中不再存在,这可能是因为您手动更改了类上的属性名称或将其删除.

在您的故事板上,选择初始视图控制器并检查是否有对名为 TextOutput 的 IBOutlet 的引用。删除该引用并再次链接视图。那应该可以解决它

【讨论】:

  • 您好,我已经更新了奥特莱斯收藏截图。我认为所有这些都是正确的
【解决方案4】:

我通过在身份检查器中为“自定义类”设置“模块”解决了这个问题

【讨论】:

    猜你喜欢
    • 2014-03-19
    • 2012-03-11
    • 1970-01-01
    • 1970-01-01
    • 2018-05-18
    • 2015-09-05
    • 2011-09-28
    • 1970-01-01
    • 2011-01-21
    相关资源
    最近更新 更多