您的位置:首页 > 移动开发 > IOS开发

iOS开发:自定义tableViewCell处理的问题

2016-01-27 19:06 351 查看
还在适配iOS6,索性下一个版本不适配了~~~~~

问题:

  

*** Assertion failure in -[ PCDiaryDetailReplyCell layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2380.17/UIView.m:5776

这个是由于在iOS6 上用了自动布局才造成的

StockOverFlow相关问题:

http://stackoverflow.com/questions/12610783/auto-layout-still-required-after-executing-layoutsubviews-with-uitableviewcel

解决办法:添加一个UITableviewCell的分类,什么都不用改动,即可

#import "UITableViewCell+FixUITableViewCellAutolayoutIHope.h"
#import <objc/runtime.h>
#import <objc/message.h>

@implementation UITableViewCell (FixUITableViewCellAutolayoutIHope)

+ (void)load
{
Method existing = class_getInstanceMethod(self, @selector(layoutSubviews));
Method new = class_getInstanceMethod(self, @selector(_autolayout_replacementLayoutSubviews));

method_exchangeImplementations(existing, new);
}

- (void)_autolayout_replacementLayoutSubviews
{
[super layoutSubviews];
[self _autolayout_replacementLayoutSubviews];
[super layoutSubviews];
}

@end
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: