首先,抱歉,如果我在这里放得太多了:我已经把我认为可能有用的所有东西都放到了帖子中。
我正在编写一个应用程序,它试图在表格 View 单元格中呈现水平 Collection View 。当没有显示 Collection View 单元格时,即我为该函数中的单元格数返回了 0,一切正常。
但是当我尝试显示一个单元格时,代码崩溃并且没有错误消息,除了 (lldb)在输出中,EXC_BREAKPOINT(code=EXC_I386_BPT, subcode=0x0) , 在 0x2d5372: movl %esi, %eax 上以绿色突出显示.
点击应用程序继续然后再次崩溃,对于需要显示的每个单元格都有相同的症状,即每次 ...cellForItemAtIndexPath...函数被调用。
我的单元格代码是:
class homeWhatsOnCellectionCell: UICollectionViewCell {
@IBOutlet var filmTitle: UILabel!
@IBOutlet var filmPoster: UIImageView!
}
Collection View 是:
class homeTableViewController: UITableViewController, UICollectionViewDelegate, UICollectionViewDataSource {
@IBOutlet var onThisWeekCollectionView: UICollectionView!
...
override func viewDidLoad() {
onThisWeekCollectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "Home Whats On Collection View Cell")
}
func collectionView(collectionView: UICollectionView!, numberOfItemsInSection section: Int) -> Int {
return 1
}
func collectionView(collectionView: UICollectionView!, cellForItemAtIndexPath indexPath: NSIndexPath!) -> UICollectionViewCell! {
var cell: homeWhatsOnCellectionCell = collectionView.dequeueReusableCellWithReuseIdentifier("Home Whats On Collection View Cell", forIndexPath: indexPath) as homeWhatsOnCellectionCell
cell.filmTitle.text = "The Hunger Games: Catching Fire"
cell.filmPoster.image = UIImage(named: "The Hunger Games.jpg")
return cell
}
func numberOfSectionsInCollectionView(collectionView: UICollectionView!) -> Int {
return 1
}
最后,单击继续最后一个无法解释的崩溃,再次崩溃并显示一条我无法弄清楚的错误消息。如果你也能解释这一点,那就加分了。我可以理解错误代码及其含义,但无法理解错误代码的原因或解决方法:
错误代码:
2014-07-24 13:19:27.237 Films 2[22583:364445] -[UICollectionViewCell filmTitle]: unrecognized selector sent to instance 0x7a185600
2014-07-24 13:19:27.240 Films 2[22583:364445] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UICollectionViewCell filmTitle]: unrecognized selector sent to instance 0x7a185600'
*** First throw call stack:
(
0 CoreFoundation 0x0058d646 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01f058bf objc_exception_throw + 44
2 CoreFoundation 0x00594fb5 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
3 CoreFoundation 0x004de617 ___forwarding___ + 1047
4 CoreFoundation 0x004de1de _CF_forwarding_prep_0 + 14
5 Films 2 0x00100954 _TFC21Films_223homeTableViewController14collectionViewfS0_FTGSQCSo16UICollectionView_22cellForItemAtIndexPathGSQCSo11NSIndexPath__GSQCSo20UICollectionViewCell_ + 980
6 Films 2 0x00100e55 _TToFC21Films_223homeTableViewController14collectionViewfS0_FTGSQCSo16UICollectionView_22cellForItemAtIndexPathGSQCSo11NSIndexPath__GSQCSo20UICollectionViewCell_ + 101
7 UIKit 0x0149747d -[UICollectionView _createPreparedCellForItemAtIndexPath:withLayoutAttributes:applyAttributes:] + 258
8 UIKit 0x01499312 -[UICollectionView _updateVisibleCellsNow:] + 4928
9 UIKit 0x0149d7bf -[UICollectionView layoutSubviews] + 263
10 UIKit 0x00e1fcf9 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 600
11 libobjc.A.dylib 0x01f18771 -[NSObject performSelector:withObject:] + 70
12 QuartzCore 0x04655f0f -[CALayer layoutSublayers] + 152
13 QuartzCore 0x04649d95 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 397
14 QuartzCore 0x04649bf0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
15 QuartzCore 0x045a925e _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 284
16 QuartzCore 0x045aa624 _ZN2CA11Transaction6commitEv + 392
17 QuartzCore 0x0466f1b9 +[CATransaction flush] + 52
18 UIKit 0x00d92e36 -[UIApplication _reportMainSceneUpdateFinished:] + 39
19 UIKit 0x00d93d2b -[UIApplication _runWithMainScene:transitionContext:completion:] + 3027
20 UIKit 0x00dac3bb __84-[UIApplication _handleApplicationActivationWithScene:transitionContext:completion:]_block_invoke + 59
21 UIKit 0x00d923c1 -[UIApplication workspaceDidEndTransaction:] + 155
22 FrontBoardServices 0x035c405e __37-[FBSWorkspace clientEndTransaction:]_block_invoke_2 + 71
23 FrontBoardServices 0x035c3ca4 __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 54
24 FrontBoardServices 0x035d56e5 __31-[FBSSerialQueue performAsync:]_block_invoke + 26
25 CoreFoundation 0x004b1450 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 16
26 CoreFoundation 0x004a66f3 __CFRunLoopDoBlocks + 195
27 CoreFoundation 0x004a654b __CFRunLoopRun + 2715
28 CoreFoundation 0x004a57eb CFRunLoopRunSpecific + 443
29 CoreFoundation 0x004a561b CFRunLoopRunInMode + 123
30 UIKit 0x00d91dd0 -[UIApplication _run] + 571
31 UIKit 0x00d953d6 UIApplicationMain + 1526
32 Films 2 0x00102841 top_level_code + 97
33 Films 2 0x0010287b main + 43
34 libdyld.dylib 0x02458ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
当它崩溃时,它会突出显示 cell.filmTitle.text = "The Hunger Games: Catching Fire"
线,我已经检查了所有 socket 是否已按应有的方式连接,据我所知,一切都应该连接良好。
最佳答案
您为重用注册了错误的类。你正在使用这个。
onThisWeekCollectionView.registerClass(UICollectionViewCell.self, forCellWithReuseIdentifier: "Home Whats On Collection View Cell")
什么时候应该使用子类。
onThisWeekCollectionView.registerClass(homeWhatsOnCellectionCell.self, forCellWithReuseIdentifier: "Home Whats On Collection View Cell")
这让我明白了你错误中有意义的部分。
-[UICollectionViewCell filmTitle]: unrecognized selector sent to instance
意味着在某处,您尝试在 UICollectionViewCell 实例上调用 filmTitle 方法,而该实例没有响应选择器,这导致了崩溃。在这种情况下,即使您在 cellForRowAtIndexPath 中向下转换,用于重用的类仍然是您的单元格父类(super class),它不会响应您的子类添加的任何方法/属性。
注意:根据标准命名约定,您的类应以大写字母开头。
关于cocoa-touch - 使用 Swift 的 iOS 应用程序崩溃时只给出 (lldb) 作为输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24933662/
我正在学习如何使用Nokogiri,根据这段代码我遇到了一些问题:require'rubygems'require'mechanize'post_agent=WWW::Mechanize.newpost_page=post_agent.get('http://www.vbulletin.org/forum/showthread.php?t=230708')puts"\nabsolutepathwithtbodygivesnil"putspost_page.parser.xpath('/html/body/div/div/div/div/div/table/tbody/tr/td/div
我有一个Ruby程序,它使用rubyzip压缩XML文件的目录树。gem。我的问题是文件开始变得很重,我想提高压缩级别,因为压缩时间不是问题。我在rubyzipdocumentation中找不到一种为创建的ZIP文件指定压缩级别的方法。有人知道如何更改此设置吗?是否有另一个允许指定压缩级别的Ruby库? 最佳答案 这是我通过查看rubyzip内部创建的代码。level=Zlib::BEST_COMPRESSIONZip::ZipOutputStream.open(zip_file)do|zip|Dir.glob("**/*")d
类classAprivatedeffooputs:fooendpublicdefbarputs:barendprivatedefzimputs:zimendprotecteddefdibputs:dibendendA的实例a=A.new测试a.foorescueputs:faila.barrescueputs:faila.zimrescueputs:faila.dibrescueputs:faila.gazrescueputs:fail测试输出failbarfailfailfail.发送测试[:foo,:bar,:zim,:dib,:gaz].each{|m|a.send(m)resc
很好奇,就使用rubyonrails自动化单元测试而言,你们正在做什么?您是否创建了一个脚本来在cron中运行rake作业并将结果邮寄给您?git中的预提交Hook?只是手动调用?我完全理解测试,但想知道在错误发生之前捕获错误的最佳实践是什么。让我们理所当然地认为测试本身是完美无缺的,并且可以正常工作。下一步是什么以确保他们在正确的时间将可能有害的结果传达给您? 最佳答案 不确定您到底想听什么,但是有几个级别的自动代码库控制:在处理某项功能时,您可以使用类似autotest的内容获得关于哪些有效,哪些无效的即时反馈。要确保您的提
假设我做了一个模块如下:m=Module.newdoclassCendend三个问题:除了对m的引用之外,还有什么方法可以访问C和m中的其他内容?我可以在创建匿名模块后为其命名吗(就像我输入“module...”一样)?如何在使用完匿名模块后将其删除,使其定义的常量不再存在? 最佳答案 三个答案:是的,使用ObjectSpace.此代码使c引用你的类(class)C不引用m:c=nilObjectSpace.each_object{|obj|c=objif(Class===objandobj.name=~/::C$/)}当然这取决于
我正在尝试使用ruby和Savon来使用网络服务。测试服务为http://www.webservicex.net/WS/WSDetails.aspx?WSID=9&CATID=2require'rubygems'require'savon'client=Savon::Client.new"http://www.webservicex.net/stockquote.asmx?WSDL"client.get_quotedo|soap|soap.body={:symbol=>"AAPL"}end返回SOAP异常。检查soap信封,在我看来soap请求没有正确的命名空间。任何人都可以建议我
关闭。这个问题是opinion-based.它目前不接受答案。想要改进这个问题?更新问题,以便editingthispost可以用事实和引用来回答它.关闭4年前。Improvethisquestion我想在固定时间创建一系列低音和高音调的哔哔声。例如:在150毫秒时发出高音调的蜂鸣声在151毫秒时发出低音调的蜂鸣声200毫秒时发出低音调的蜂鸣声250毫秒的高音调蜂鸣声有没有办法在Ruby或Python中做到这一点?我真的不在乎输出编码是什么(.wav、.mp3、.ogg等等),但我确实想创建一个输出文件。
我在我的项目目录中完成了compasscreate.和compassinitrails。几个问题:我已将我的.sass文件放在public/stylesheets中。这是放置它们的正确位置吗?当我运行compasswatch时,它不会自动编译这些.sass文件。我必须手动指定文件:compasswatchpublic/stylesheets/myfile.sass等。如何让它自动运行?文件ie.css、print.css和screen.css已放在stylesheets/compiled。如何在编译后不让它们重新出现的情况下删除它们?我自己编译的.sass文件编译成compiled/t
对于具有离线功能的智能手机应用程序,我正在为Xml文件创建单向文本同步。我希望我的服务器将增量/差异(例如GNU差异补丁)发送到目标设备。这是计划:Time=0Server:hasversion_1ofXmlfile(~800kiB)Client:hasversion_1ofXmlfile(~800kiB)Time=1Server:hasversion_1andversion_2ofXmlfile(each~800kiB)computesdeltaoftheseversions(=patch)(~10kiB)sendspatchtoClient(~10kiBtransferred)Cl
我想将html转换为纯文本。不过,我不想只删除标签,我想智能地保留尽可能多的格式。为插入换行符标签,检测段落并格式化它们等。输入非常简单,通常是格式良好的html(不是整个文档,只是一堆内容,通常没有anchor或图像)。我可以将几个正则表达式放在一起,让我达到80%,但我认为可能有一些现有的解决方案更智能。 最佳答案 首先,不要尝试为此使用正则表达式。很有可能你会想出一个脆弱/脆弱的解决方案,它会随着HTML的变化而崩溃,或者很难管理和维护。您可以使用Nokogiri快速解析HTML并提取文本:require'nokogiri'h