小编sel*_*ame的帖子

UICollectionView + iOS 7/Xcode 5 =断言失败

在我的应用程序中有一个使用flowLayout的UICollectionView,它在iOS 6中工作得非常漂亮,但在iOS 7中失败了.只要我看到包含我的UICollectionView的视图,就会发生以下情况:

*** Assertion failure in -[UICollectionView _createPreparedSupplementaryViewForElementOfKind:atIndexPath:withLayoutAttributes:applyAttributes:], /SourceCache/UIKit/UIKit-2903.2/UICollectionView.m:1401
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'the view returned from -collectionView:viewForSupplementaryElementOfKind:atIndexPath
(UICollectionElementKindSectionHeader,<NSIndexPath: 0x145f3f50> {length = 2, path = 0 - 0}) was not retrieved by calling -dequeueReusableSupplementaryViewOfKind:withReuseIdentifier:forIndexPath: or is nil'
(<UICollectionReusableView: 0x145f9400; frame = (0 0; 320 20); layer = <CALayer: 0x145f90c0>>)
Run Code Online (Sandbox Code Playgroud)

uncaught-exception uicollectionview ios7 xcode5

7
推荐指数
2
解决办法
1万
查看次数

UIView子类未收到NSNotificationCenter通知

我之前使用过NSNotificationCenter进行应用程序范围的消息传递,但今天我发现了一个奇怪的漏洞.在客户的项目上工作有一些UIView子类需要接收我已经在应用程序中的其他地方发布/接收的NSNotifications.

我从init方法调用addObserver:self并使用#defined常量作为通知名称.当我注册接收的通知被发布时,正在侦听的所有其他对象(所有UIViewController子类)都会获得除我的UIView子类之外的通知.

有没有人成功使用过UIView子类中的NSNotificationCenter?我已经尝试过断点和NSLog,但我的@selector永远不会被调用.

编辑 - 视图是使用loadNibNamed创建的:并且initWithCoder:未在类中实现.在initWithCoder中注册通知:效果很好.

objective-c uiview nsnotification nsnotificationcenter ios

1
推荐指数
1
解决办法
1225
查看次数