ios - 在 Xcode 项目上实现第三方库时出错
问题描述
我正在尝试使用第三方库 TTFortuneWheel 来构建应用程序。以下代码是我添加到这个新项目中的代码。
当我运行该应用程序时,它显示此错误:EXC_BAD_ACCESS (code=2, address=0x10e5c8dd8)
class ViewController: UIViewController {
@IBOutlet weak var spinningWheel: TTFortuneWheel!
override func viewDidLoad() {
super.viewDidLoad()
let slices = [ FortuneWheelSlice(title: "Slice 1"),
FortuneWheelSlice(title: "Slice 2"),
FortuneWheelSlice(title: "Slice 3")]
let frame = spinningWheel.frame
let fortuneWheel = TTFortuneWheel(frame: frame, slices: slices)
spinningWheel.equalSlices = true
self.view.addSubview(fortuneWheel)
我也试过下面的代码,它是从 TTFortuneWheel 的示例中修改并在示例项目上成功运行,但是在我的项目中运行时显示另一个错误:EXC_BAD_ACCESS (code=EXC_I386_GPFLT)
let slices = [ FortuneWheelSlice.init(title: "Roller Coaster"),
FortuneWheelSlice.init(title: "Try again"),
FortuneWheelSlice.init(title: "Free\nticket"),
FortuneWheelSlice.init(title: "Teddy\nbear"),
FortuneWheelSlice.init(title: "Large popcorn"),
FortuneWheelSlice.init(title: "Balloon figures"),
FortuneWheelSlice.init(title: "Ferris Wheel"),
FortuneWheelSlice.init(title: "Pony\nRide")]
spinningWheel.slices = slices
spinningWheel.equalSlices = true
spinningWheel.frameStroke.width = 0
spinningWheel.slices.enumerated().forEach { (pair) in
let slice = pair.element as! FortuneWheelSlice
let offset = pair.offset
switch offset % 4 {
case 0: slice.style = .dark
case 1: slice.style = .light
case 2: slice.style = .dark
case 3: slice.style = .light
default: slice.style = .dark
}
}
我已经尝试解决这些问题一周并通读了 TTFortuneWheel 的所有文件。如果有人能帮助我解决这些错误或帮助我正确使用 TTFortuneWheel,我将不胜感激!
调用堆栈:
0 MyApp 0x0000000106449cc7 $s13MyApp14ViewControllerC11viewDidLoadyyF + 311
1 MyApp 0x000000010644a6c4 $s13MyApp14ViewControllerC11viewDidLoadyyFTo + 36
2 UIKitCore 0x00000001104f343b -[UIViewController loadViewIfRequired] + 1183
3 UIKitCore 0x00000001104f3868 -[UIViewController view] + 27
4 UIKitCore 0x0000000110b2bc33 -[UIWindow addRootViewControllerViewIfPossible] + 122
5 UIKitCore 0x0000000110b2c327 -[UIWindow _setHidden:forced:] + 289
6 UIKitCore 0x0000000110b3ef86 -[UIWindow makeKeyAndVisible] + 42
7 UIKitCore 0x0000000110aeef1c -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4555
8 UIKitCore 0x0000000110af40c6 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1617
9 UIKitCore 0x00000001103396d6 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 904
10 UIKitCore 0x0000000110341fce +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
11 UIKitCore 0x00000001103392ec -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
12 UIKitCore 0x0000000110339c48 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1091
13 UIKitCore 0x0000000110337fba __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 782
14 UIKitCore 0x0000000110337c71 -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 433
15 UIKitCore 0x000000011033c9b6 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 576
16 UIKitCore 0x000000011033d610 _performActionsWithDelayForTransitionContext + 100
17 UIKitCore 0x000000011033c71d -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 223
18 UIKitCore 0x00000001103416d0 -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
19 UIKitCore 0x0000000110af29a8 -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 514
20 UIKitCore 0x00000001106a9dfa -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 361
21 FrontBoardServices 0x0000000113934125 -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448
22 FrontBoardServices 0x000000011393ded6 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 283
23 FrontBoardServices 0x000000011393d700 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53
24 libdispatch.dylib 0x000000010a5c4db5 _dispatch_client_callout + 8
25 libdispatch.dylib 0x000000010a5c82ba _dispatch_block_invoke_direct + 300
26 FrontBoardServices 0x000000011396f146 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
27 FrontBoardServices 0x000000011396edfe -[FBSSerialQueue _performNext] + 451
28 FrontBoardServices 0x000000011396f393 -[FBSSerialQueue _performNextFromRunLoopSource] + 42
29 CoreFoundation 0x0000000109198be1 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
30 CoreFoundation 0x0000000109198463 __CFRunLoopDoSources0 + 243
31 CoreFoundation 0x0000000109192b1f __CFRunLoopRun + 1231
32 CoreFoundation 0x0000000109192302 CFRunLoopRunSpecific + 626
33 GraphicsServices 0x000000010cff52fe GSEventRunModal + 65
34 UIKitCore 0x0000000110af5ba2 UIApplicationMain + 140
35 MyApp 0x000000010644b77b main + 75
36 libdyld.dylib 0x000000010a639541 start + 1
37 ???
解决方案
推荐阅读
- reactjs - 如何在 React Native 中的 post request fetch api 调用中传递正文
- paypal - 如何使用信用卡将 ionic 自动付款与 paypal 集成
- javascript - Javascript 中是否有一种简单的方法可以将参数化事件侦听器添加到动态生成的 HTML 元素中?
- vb.net - ToString("C") 在 VB 中未显示预期结果
- java - 在 Spring webflux 通量响应中将一个响应对象转换为另一个对象(pojo)而不订阅它
- c++ - 使用 C++ 挂载函数挂载 ecryptfs
- javascript - 如何在 NodeJS 中根据空间拆分数组?
- c - 如何将 C 结构传递给 Rust?
- node.js - express 创建的 localhost:3000 服务器是什么意思?
- arrays - F#无反射向下转换数组