- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我已经从 cocoapods 安装了 PSCarouselView 到我的项目。当我尝试使用这个库时,我遇到了运行时错误。并且错误提示无法加载 nib 文件...
我已经检查了库,发现 nib 文件已正确注册。而且我还检查了目标成员资格并选中了复选框。然后我检查 podspec 文件,找不到任何关于该库的 podspec,然后我为该库创建了一个 pod 规范文件。使用下面的命令
pod spec create [PSCarouselView]https://github.com/DeveloperPans/PSCarouselView
然后我可以检查 podspec 文件并添加以下命令;
s.resources = "Resources/*.xib"
s.resource_bundles = {
'PSCarouselView' => [
'Pod/**/*.xib'
实际上,在我将此命令添加到 podspec 之前,xib 文件已复制到我的项目中。我只是拼命地尝试...
用如下代码注册的xib文件;
[self registerNib:[UINib nibWithNibName:@"PSCarouselCollectionCell" bundle:nil] forCellWithReuseIdentifier:@"PSCarouselCollectionCell"];
标识符也定义正确;
所以现在我很绝望如何解决这个问题。
我在下面分享错误;
MyTestApp[18232:1316081] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/adminuser/Library/Developer/CoreSimulator/Devices/464AB3F8-3C31-4473-AD1B-F554F3F59CDB/data/Containers/Bundle/Application/B4A5F964-A6E0-4357-878F-11A299FD1ACA/MyTestApp.app> (loaded)' with name 'PSCarouselCollectionCell''
*** First throw call stack:
(
0 CoreFoundation 0x0000000101598d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010100cdeb objc_exception_throw + 48
2 CoreFoundation 0x0000000101598cbd +[NSException raise:format:] + 205
3 UIKit 0x00000001023dec89 -[UINib instantiateWithOwner:options:] + 499
4 UIKit 0x000000010289f553 -[UICollectionView _dequeueReusableViewOfKind:withIdentifier:forIndexPath:viewCategory:] + 716
5 UIKit 0x000000010289febc -[UICollectionView dequeueReusableCellWithReuseIdentifier:forIndexPath:] + 169
6 PSCarouselView 0x0000000100b13b92 -[PSCarouselView collectionView:cellForItemAtIndexPath:] + 114
7 UIKit 0x000000010288e08f -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:isFocused:] + 483
8 UIKit 0x0000000102891d96 -[UICollectionView _updateVisibleCellsNow:] + 4988
9 UIKit 0x0000000102896575 -[UICollectionView layoutSubviews] + 258
10 PSCarouselView 0x0000000100b13108 -[PSCarouselView layoutSubviews] + 328
11 UIKit 0x00000001020d1980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
12 QuartzCore 0x0000000105065c00 -[CALayer layoutSublayers] + 146
13 QuartzCore 0x000000010505a08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
14 UIKit 0x00000001020c1205 -[UIView(Hierarchy) layoutBelowIfNeeded] + 1129
15 UIKit 0x00000001021f65c5 -[UINavigationController _layoutViewController:] + 1613
16 UIKit 0x00000001021f53b4 -[UINavigationController _layoutTopViewController] + 268
17 UIKit 0x00000001021f26bd -[UINavigationController navigationTransitionView:didEndTransition:fromView:toView:] + 856
18 UIKit 0x000000010249cc2c -[UINavigationTransitionView _notifyDelegateTransitionDidStopWithContext:] + 422
19 UIKit 0x000000010249cfa2 -[UINavigationTransitionView _cleanupTransition] + 788
20 UIKit 0x00000001020a47ff -[UIViewAnimationState sendDelegateAnimationDidStop:finished:] + 241
21 UIKit 0x00000001020a1706 +[UIViewAnimationState popAnimationState] + 314
22 UIKit 0x000000010249c8dd -[UINavigationTransitionView transition:fromView:toView:] + 2640
23 UIKit 0x00000001021f7651 -[UINavigationController _startTransition:fromViewController:toViewController:] + 3291
24 UIKit 0x00000001021f7c4d -[UINavigationController _startDeferredTransitionIfNeeded:] + 890
25 UIKit 0x00000001021f8d0b -[UINavigationController __viewWillLayoutSubviews] + 57
26 UIKit 0x00000001023a7503 -[UILayoutContainerView layoutSubviews] + 248
27 UIKit 0x00000001020d1980 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 703
28 QuartzCore 0x0000000105065c00 -[CALayer layoutSublayers] + 146
29 QuartzCore 0x000000010505a08e _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
30 QuartzCore 0x0000000105059f0c _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
31 QuartzCore 0x000000010504e3c9 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 277
32 QuartzCore 0x000000010507c086 _ZN2CA11Transaction6commitEv + 486
33 QuartzCore 0x000000010507c7f8 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 92
34 CoreFoundation 0x00000001014bdc37 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
35 CoreFoundation 0x00000001014bdba7 __CFRunLoopDoObservers + 391
36 CoreFoundation 0x00000001014b311c CFRunLoopRunSpecific + 524
37 UIKit 0x0000000102011f21 -[UIApplication _run] + 402
38 UIKit 0x0000000102016f09 UIApplicationMain + 171
39 MyTestApp 0x0000000100a598b2 main + 114
40 libdyld.dylib 0x0000000107d9a92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
最佳答案
如果与您的 .xib(本例中为 YourView.xib)的 bundle 在一个 pods bundle 中,您可以通过这种方式在文件所有者 UIView 子类中检索 bundle 。
let bundle = Bundle(for: self.classForCoder)
然后实例化 View :
nib.instantiate(withOwner: self, options: nil)
let nib = UINib(nibName: "YourView", bundle: bundle)
如果您想在 pod 模块之外子类化以这种方式加载的 UIView,最好使用下面的内容,因为“self.classForCoder”将为您提供子类所在的包。
let bundle = Bundle(for: <FileOwnerUIViewSubclass>.classForCoder())
关于ios - 无法在捆绑 CocoaPods 中加载 NIB,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38447706/
有没有办法在 CocoaPod 文件中写入注释?我看了他们的CocoaPods Guide ,但我什么也没看到。 最佳答案 您可以使用 Ruby 注释语法在 Podfile 中添加注释: 内联 #co
我在 Xcode 项目中有多个目标,它们必须依赖于相同的 pod 列表。我可以这样写 Podfile: target :target1 do pod 'pod1' pod 'pod2'
我正在创建一个新的 cocoapod,并希望包含另一个 cocoapod 作为依赖项。 我在 podspec 中添加了必要的行: s.dependency 'Locksmith', '~> 2.0
我执行了我的正常 pod update并收到以下消息: [!] There was an error reading '~/.cocoapods/repos/master/CocoaPods-vers
背景 几年前,我为我正在从事的项目安装了 cocoapods。从那以后我就没有使用过它,现在我需要更新它才能让 Flutter 工作。 系统 操作系统 MacOS Mojave 版本 10.14.3
我想知道用 CocoaPod 包含演示项目的最佳方法是什么。特别是,我希望它成为任何人都可以尝试使用 pod try 的组件。命令。 我看到两个选项: 选项 1:使用 Podfile 在 Exampl
我正在尝试为 firebase 获取一个 pod,但是我在搜索框中输入的任何名称都没有返回任何内容。是网站打不开还是?谢谢 最佳答案 这似乎是许多开发人员不时面临的问题,包括我自己,但是 cocoap
我有一个库的公共(public)分支,该库已存在于 CocoaPods/Specs 中。在 Podfile 中,我可以通过执行以下操作来引用此 fork pod: pod 'CoolLibrary',
pod 命令是否支持列出给定项目中已安装的 CococaPods 的选项? pod list 似乎显示了所有已发布 pod 的列表。我查看了文档,但找不到执行此操作的方法。 最佳答案 如 @DougA
我在 Amazon s3 中存储了一个预编译的框架。 “pod spec lint”失败并出现以下错误。 - ERROR | [iOS] file patterns: The `source_file
我正在用一些资源文件创建我自己的 pod。它基本上是这样定义的: Pod::Spec.new do |s| s.name = 'MyName' s.version = '0.
我正在尝试在我的项目中使用编译到 iOS 的 libFLAC,并使用 CocoaPod 作为依赖项进行安装。 问题是,如果我使用 CocoaPod 0.39 版,工作区创建得很好,但如果我使用 Coc
我在使 CocoaPods 依赖项在 RubyMotion 中工作时遇到了各种问题。首先,如果我添加 dependency 'JSONKit'到我的 Rakefile 然后运行 rake它被 ca
当使用 faSTLane 和 cocoapods 构建我们的 iOS 应用程序时,我注意到 faSTLane 不使用我使用安装的 cocoapods 版本 sudo gem install cocoa
有没有办法在 Podfile 中指定那个 xcconfig文件应该是 #include d 在 Cocoapods 生成的那个? 是否有公开的方法/变量用于附加此 #include还是我需要阅读生成的
在新的 XCode5 中构建我的项目时,我收到以下警告: Pods-App 作为“libPods-App.a”的隐式依赖项被拒绝,因为其架构“i386”不包含所有必需的架构“x86_64” . 最佳答
我已经使用以下命令在 bundle 中安装了 Cocoapods-art: bundle exec gem install cocoapods-art 这是成功消息: Fetching cocoap
在 Xcode 7 中,cocoapods 库的库具有排除代码覆盖率的功能。 但在 Xcode 8 中,该库将包含代码覆盖率。 我是否可以在代码覆盖率中排除该库? 示例:安装 pod 'TPKeybo
我目前正在寻找一个仅支持 Carthage 作为包管理器的库。我希望将其集成的项目已经有一些 CocoaPods 依赖项。有人尝试过同时使用这两个管理器吗? 我觉得这是一个坏主意,但我很想听听实际情况
我刚刚在 Specs Repo 中使用 Pod trunk Push 发布了 Pod 的 Beta 版本。我想知道是否有任何方法可以从规范存储库中删除此版本规范。我没有找到任何通过 pod 命令执行此
我是一名优秀的程序员,十分优秀!