Code Monkey home page Code Monkey logo

uitableview-fdtemplatelayoutcell's Introduction

UITableView-FDTemplateLayoutCell

Overview

Template auto layout cell for automatically UITableViewCell height calculating.

Demo Overview

Basic usage

If you have a self-satisfied cell, then all you have to do is:

#import "UITableView+FDTemplateLayoutCell.h"

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [tableView fd_heightForCellWithIdentifier:@"reuse identifer" configuration:^(id cell) {
        // Configure this cell with data, same as what you've done in "-tableView:cellForRowAtIndexPath:"
        // Like:
        //    cell.entity = self.feedEntities[indexPath.row];
    }];
}

Height Caching API

Since iOS8, -tableView:heightForRowAtIndexPath: will be called more times than we expect, we can feel these extra calculations when scrolling. So we provide another API with cache by index path:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return [tableView fd_heightForCellWithIdentifier:@"identifer" cacheByIndexPath:indexPath configuration:^(id cell) {
        // configurations
    }];
}

Or, if your entity has an unique identifier, use cache by key API:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
	Entity *entity = self.entities[indexPath.row];
    return [tableView fd_heightForCellWithIdentifier:@"identifer" cacheByKey:entity.uid configuration:^(id cell) {
        // configurations
    }];
}

Frame layout mode

FDTemplateLayoutCell offers 2 modes for asking cell's height.

  1. Auto layout mode using "-systemLayoutSizeFittingSize:"
  2. Frame layout mode using "-sizeThatFits:"

Generally, no need to care about modes, it will automatically choose a proper mode by whether you have set auto layout constrants on cell's content view. If you want to enforce frame layout mode, enable this property in your cell's configuration block:

cell.fd_enforceFrameLayout = YES;

And if you're using frame layout mode, you must override -sizeThatFits: in your customized cell and return content view's height (separator excluded)

- (CGSize)sizeThatFits:(CGSize)size {
    return CGSizeMake(size.width, A+B+C+D+E+....);
}

Debug log

Debug log helps to debug or inspect what is this "FDTemplateLayoutCell" extention doing, turning on to print logs when "calculating", "precaching" or "hitting cache".Default to "NO", log by "NSLog".

self.tableView.fd_debugLogEnabled = YES;

It will print like this:

** FDTemplateLayoutCell ** layout cell created - FDFeedCell
** FDTemplateLayoutCell ** calculate - [0:0] 233.5
** FDTemplateLayoutCell ** calculate - [0:1] 155.5
** FDTemplateLayoutCell ** calculate - [0:2] 258
** FDTemplateLayoutCell ** calculate - [0:3] 284
** FDTemplateLayoutCell ** precached - [0:3] 284
** FDTemplateLayoutCell ** calculate - [0:4] 278.5
** FDTemplateLayoutCell ** precached - [0:4] 278.5
** FDTemplateLayoutCell ** hit cache - [0:3] 284
** FDTemplateLayoutCell ** hit cache - [0:4] 278.5
** FDTemplateLayoutCell ** hit cache - [0:5] 156
** FDTemplateLayoutCell ** hit cache - [0:6] 165

About self-satisfied cell

a fully self-satisfied cell is constrainted by auto layout and each edge("top", "left", "bottom", "right") has at least one layout constraint against it. It's the same concept introduced as "self-sizing cell" in iOS8 using auto layout.

A bad one :( - missing right and bottom non-self-satisfied

A good one :)
self-satisfied

Notes

A template layout cell is created by -dequeueReusableCellWithIdentifier: method, it means that you MUST have registered this cell reuse identifier by one of:

  • A prototype cell of UITableView in storyboard.
  • Use -registerNib:forCellReuseIdentifier:
  • Use -registerClass:forCellReuseIdentifier:

如果你在天朝

可以看这篇中文博客: http://blog.sunnyxx.com/2015/05/17/cell-height-calculation/

Installation

Latest version: 1.6

pod search UITableView+FDTemplateLayoutCell 

If you cannot search out the latest version, try:

pod setup

Release Notes

We recommend to use the latest release in cocoapods.

  • 1.6 fix bug in iOS 10

  • 1.4
    Refactor, add "cacheByKey" mode, bug fixed

  • 1.3
    Frame layout mode, handle cell's accessory view/type

  • 1.2
    Precache and auto cache invalidation

  • 1.1
    Height cache

  • 1.0
    Basic automatically height calculation

License

MIT

uitableview-fdtemplatelayoutcell's People

Contributors

nickqiao avatar philcn avatar sunnyxx avatar wangyutao0424 avatar weekwood avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

uitableview-fdtemplatelayoutcell's Issues

uilabel in cell,you set hard width constraint,if use preferredMaxLayoutWidth

// Add a hard width constraint to make dynamic content views (like labels) expand vertically instead
// of growing horizontally, in a flow-layout manner.

It is good idea, but if i use preferredMaxLayoutWidth for uilabel,width constraint is not essential,is that right?

ps: before using systemLayoutSizeFittingSize, setNeedsLayout() and layoutIfNeeded() is not need call?

Demo中先Delete a section然后再Insert a row,就崩溃了

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid update: invalid number of sections. The number of sections contained in the table view after the update (1) must be equal to the number of sections contained in the table view before the update (0), plus or minus the number of sections inserted or deleted (0 inserted, 0 deleted).'
*** First throw call stack:
(
0 CoreFoundation 0x008a5746 exceptionPreprocess + 182
1 libobjc.A.dylib 0x0052ea97 objc_exception_throw + 44
2 CoreFoundation 0x008a55da +[NSException raise:format:arguments:] + 138
3 Foundation 0x0019b720 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 118
4 UIKit 0x00f79cfc -[UITableView _endCellAnimationsWithContext:] + 13530
5 UIKit 0x00f90d81 -[UITableView _updateRowsAtIndexPaths:updateAction:withRowAnimation:] + 337
6 UIKit 0x00f90dc1 -[UITableView insertRowsAtIndexPaths:withRowAnimation:] + 56
7 Demo 0x0003c678 -[UITableView(FDTemplateLayoutCellAutomaticallyCacheInvalidation) fd_insertRowsAtIndexPaths:withRowAnimation:] + 344
8 Demo 0x00040bb0 -[FDFeedViewController insertRow] + 704
9 Demo 0x000407a5 -[FDFeedViewController actionSheet:clickedButtonAtIndex:] + 181
10 UIKit 0x01463031 -[UIActionSheet _prepareToDismissForTappedIndex:] + 192
11 UIKit 0x01462f09 __37-[UIActionSheet _prepareAlertActions]_block_invoke114 + 56
12 UIKit 0x0114233f -[UIAlertController _dismissAnimated:triggeringAction:triggeredByPopoverDimmingView:] + 72
13 UIKit 0x011422f2 -[UIAlertController _dismissAnimated:triggeringAction:] + 56
14 UIKit 0x01141ede -[UIAlertController _actionViewTapped:] + 68
15 libobjc.A.dylib 0x00544771 -[NSObject performSelector:withObject:] + 70
16 UIKit 0x01313465 -[_UIAlertControllerActionView _triggerSelect] + 60
17 UIKit 0x013130ac -[_UIAlertControllerActionView touchesEnded:withEvent:] + 187
18 UIKit 0x00ed0cfa -[UIWindow _sendTouchesForEvent:] + 874
19 UIKit 0x00ed17d6 -[UIWindow sendEvent:] + 792
20 UIKit 0x00e8f6d1 -[UIApplication sendEvent:] + 242
21 UIKit 0x00e9fb08 _UIApplicationHandleEventFromQueueEvent + 21484
22 UIKit 0x00e73337 _UIApplicationHandleEventQueue + 2300
23 CoreFoundation 0x007c706f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION
+ 15
24 CoreFoundation 0x007bcb7d __CFRunLoopDoSources0 + 253
25 CoreFoundation 0x007bc0d8 __CFRunLoopRun + 952
26 CoreFoundation 0x007bba5b CFRunLoopRunSpecific + 443
27 CoreFoundation 0x007bb88b CFRunLoopRunInMode + 123
28 GraphicsServices 0x049602c9 GSEventRunModal + 192
29 GraphicsServices 0x04960106 GSEventRun + 104
30 UIKit 0x00e77106 UIApplicationMain + 1526
31 Demo 0x00041cea main + 138
32 libdyld.dylib 0x02e44ac9 start + 1
33 ??? 0x00000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

没有移除observer?

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x130222c00 of class UITableView was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x174445e50> (
<NSKeyValueObservance 0x1742d19c0: Observer: 0x12f561dc0, Key path: contentOffset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x17424bfd0>
<NSKeyValueObservance 0x1742d1b80: Observer: 0x12f561dc0, Key path: contentSize, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x17424c150>
<NSKeyValueObservance 0x1742d1bf0: Observer: 0x12f561dc0, Key path: frame, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x17424c2a0>
<NSKeyValueObservance 0x1742d1640: Observer: 0x12f561dc0, Key path: contentInset, Options: <New: YES, Old: NO, Prior: NO> Context: 0x0, Property: 0x17424c240>
)'

崩溃在

  • (void)fd_insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
    {
    if (self.fd_autoCacheInvalidationEnabled) {
    [indexPaths enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger idx, BOOL *stop) {
    NSMutableArray *rows = self.fd_cellHeightCache.sections[indexPath.section];
    [rows insertObject:@(_FDTemplateLayoutCellHeightCacheAbsentValue) atIndex:indexPath.row];
    }];
    }
    [self fd_insertRowsAtIndexPaths:indexPaths withRowAnimation:animation]; // Primary call
    [self fd_precacheIfNeeded];
    }

同一个Cell内两个动态高度Label会导致其中一个计算不正确

同一个Cell会用到某两个Label需要动态高度,经过测试一般都是第二个Label高度会不对,是我约束设置的不对吗?如果是上述情况,需要动态高度的Label需要怎么设置高度呢?
目前解决方法只能:
[cell updateConstraintsIfNeeded];
[cell layoutIfNeeded];

ios8以上的系统cell.contentView.constraints 是个空数组

使用Xib布局 registerNib:forCellReuseIdentifier:注册了Cell
计算高度时
BOOL autoLayoutEnabled = cell.contentView.constraints.count > 0 && !cell.fd_enforceFrameLayout;
这句中的cell.contentView.constraints 是个空数组 但是我用了AutoLayout了

一定要用nib吗?

我的cell是代码写的可以吗?不用nib的画,fd_templateCellForReuseIdentifier这个方法就会断言必需注册identifier,并退出程序。

rotations

Amazing library, I'm using it a lot! ... but I found a problem :P

Looks like rotations and caching are not good friends right now.

I have two ideas

  1. Have sections per orientation (landscape/portrait)
  2. Clear sections on rotate. Handle the event through the notification center or similar.

Demo crash

Delete all setions;
insert a row;

Tableview的锅,但是demo crash玩着玩着crash总归不太好吧。

fd_heightForCellWithIdentifier: cacheByIndexPath crushed app

The uncached version works without any problems.I tried to use the cached version:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [tableView fd_heightForCellWithIdentifier:@"identifer" cacheByIndexPath:indexPath configuration:^(id cell) {
        // configurations
    }];
}

I used it on the collapse table view example Apple provided here:

https://developer.apple.com/library/ios/samplecode/TableViewUpdates/Introduction/Intro.html

When I tap on a table header cell open works great with the correct height calculated using auto layout. When I tap again on the same header cell to close the section the following error occurs:

2015-06-18 16:20:59.911 HotelRoomServiceDemo[10042:607] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM removeObjectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(
    0   CoreFoundation                      0x00b111e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x0088c8e5 objc_exception_throw + 44
    2   CoreFoundation                      0x00ab25ba -[__NSArrayM removeObjectAtIndex:] + 442
    3   HotelRoomServiceDemo                0x000ea3c9 __110-[UITableView(FDTemplateLayoutCellAutomaticallyCacheInvalidation) fd_deleteRowsAtIndexPaths:withRowAnimation:]_block_invoke + 297
    4   CoreFoundation                      0x00b8d99d __53-[__NSArrayI enumerateObjectsWithOptions:usingBlock:]_block_invoke + 61
    5   CoreFoundation                      0x00b8d8d2 -[__NSArrayI enumerateObjectsWithOptions:usingBlock:] + 258
    6   CoreFoundation                      0x00b0aca5 -[NSArray enumerateObjectsUsingBlock:] + 53
    7   HotelRoomServiceDemo                0x000ea23a -[UITableView(FDTemplateLayoutCellAutomaticallyCacheInvalidation) fd_deleteRowsAtIndexPaths:withRowAnimation:] + 282
    8   UIKit                               0x0c351da6 -[UITableViewAccessibility(Accessibility) deleteRowsAtIndexPaths:withRowAnimation:] + 65
    9   HotelRoomServiceDemo                0x00099ed9 _TFC20HotelRoomServiceDemo29MMCollapseTableViewController17sectionHeaderViewfS0_FTCS_26MMCollapseTableSectionView13sectionClosedSi_T_ + 1273
    10  HotelRoomServiceDemo                0x0009a730 _TTWC20HotelRoomServiceDemo29MMCollapseTableViewControllerS_34MMCollapseTableSectionViewDelegateS_FS1_17sectionHeaderViewUS1___fQPS1_FTCS_26MMCollapseTableSectionView13sectionClosedSi_T_ + 32
    11  HotelRoomServiceDemo                0x00090185 _TFC20HotelRoomServiceDemo26MMCollapseTableSectionView24toggleOpenWithUserActionfS0_FSbT_ + 1589
    12  HotelRoomServiceDemo                0x00090249 _TFC20HotelRoomServiceDemo26MMCollapseTableSectionView10toggleOpenfS0_FT_T_ + 57
    13  HotelRoomServiceDemo                0x00090282 _TToFC20HotelRoomServiceDemo26MMCollapseTableSectionView10toggleOpenfS0_FT_T_ + 34
    14  UIKit                               0x013214f4 _UIGestureRecognizerSendActions + 230
    15  UIKit                               0x01320168 -[UIGestureRecognizer _updateGestureWithEvent:buttonEvent:] + 383
    16  UIKit                               0x01321bdd -[UIGestureRecognizer _delayedUpdateGesture] + 60
    17  UIKit                               0x0132513d ___UIGestureRecognizerUpdate_block_invoke + 57
    18  UIKit                               0x013250be _UIGestureRecognizerRemoveObjectsFromArrayAndApplyBlocks + 317
    19  UIKit                               0x0131b7ac _UIGestureRecognizerUpdate + 199
    20  UIKit                               0x00fc6a5a -[UIWindow _sendGesturesForEvent:] + 1291
    21  UIKit                               0x00fc7971 -[UIWindow sendEvent:] + 1021
    22  UIKit                               0x00f995f2 -[UIApplication sendEvent:] + 242
    23  UIKit                               0x00f83353 _UIApplicationHandleEventQueue + 11455
    24  CoreFoundation                      0x00a9a77f __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
    25  CoreFoundation                      0x00a9a10b __CFRunLoopDoSources0 + 235
    26  CoreFoundation                      0x00ab71ae __CFRunLoopRun + 910
    27  CoreFoundation                      0x00ab69d3 CFRunLoopRunSpecific + 467
    28  CoreFoundation                      0x00ab67eb CFRunLoopRunInMode + 123
    29  GraphicsServices                    0x038ac5ee GSEventRunModal + 192
    30  GraphicsServices                    0x038ac42b GSEventRun + 104
    31  UIKit                               0x00f85f9b UIApplicationMain + 1225
    32  HotelRoomServiceDemo                0x000ada94 main + 180
    33  libdyld.dylib                       0x034c76d9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

How to call it in swift?

tableView.fd_heightForCellWithIdentifier("cellId", configuration: { (cell:UITableviewCell) -> Void in
self.configureCell(cell, atIndexPath: indexPath)
})

does not work

How to use without storyboard?

I am using xibs in my project. I followed your guidelines. But, still I am not able to make it work with xib.

Please provide the details, for how to add it with xib.

单行删除一个indexPath,没有任何问题,如果是一次删除多个indexPath,就会有问题

- (void)fd_deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation
{
    if (self.fd_autoCacheInvalidationEnabled) {
        [self.fd_cellHeightCache buildHeightCachesAtIndexPathsIfNeeded:indexPaths];
        [indexPaths enumerateObjectsUsingBlock:^(NSIndexPath *indexPath, NSUInteger idx, BOOL *stop) {
            NSMutableArray *rows = self.fd_cellHeightCache.sections[indexPath.section];
            [rows removeObjectAtIndex:indexPath.row];
        }];
    }
    [self fd_deleteRowsAtIndexPaths:indexPaths withRowAnimation:animation]; // Primary call
}

it doesn't work when content contains dynamic image view

I have one image view inside cell content that loads photo from server.
image view content mode is aspect fill and only width has been defined using autolayout in storyboard.
height should be increased dynamically based on loaded photo size.
constraints for cell content view has been already self-satisfied.
what am I missing?

加入上拉加载更多后,待加载完毕数据reload data,再向下滑动返回到头部,会出现跳动

如题,解决方案:

//@note:这种解决方案在iOS 7.0+能很好的解决问题,但是如若解决iOS 6.0的话,则无效了。
- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return [tableView fd_heightForCellWithIdentifier:@"xxxxCellIdentifier"
                                    cacheByIndexPath:indexPath
                                       configuration:^(xxxCell *cell) {
                                           [self configureCell:cell atIndexPath:indexPath];
                                       }];
}

如果没有用autoLayout的话,那返回的高度都会是0.

//解决办法就是在获取高度之后判断一下,是否为空,如果为空的话,那就用cell的高度设置一下就可以了。
CGSize fittingSize = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize];
if (fittingSize.height == 0) {
fittingSize.height = cell.frame.size.height;
}

Using SDWebImage to download imageUrl

When you use SDWebImage to download pictures, the height of the image in cell is elongated。Images are not adaptive cell good height。Hope to improve it

Contraints leads to conflicts

I used it on the collapse table view example Apple provided here:

https://developer.apple.com/library/ios/samplecode/TableViewUpdates/Introduction/Intro.html

I used the not cached version of this plugin. When I click on a section header to open the rows in the section then I get the following error:

Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<_UIScrollViewAutomaticContentSizeConstraint:0x7a09e6a0 UITableView:0x7c1d4400.contentHeight{id: 178} == -5.000000>"
)

Will attempt to recover by breaking constraint 
<_UIScrollViewAutomaticContentSizeConstraint:0x7a09e6a0 UITableView:0x7c1d4400.contentHeight{id: 178} == -5.000000>

Break on objc_exception_throw to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKit/UIView.h> may also be helpful.

My Custom Cell looks like this:

class MyCell: UITableViewCell {

   override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
      super.init(style: style, reuseIdentifier: reuseIdentifier)
      setupView()
   }

   private func setupView() {
      let addButton = UIButton.buttonWithType(UIButtonType.Custom) as! UIButton 
      self.contentView.addSubview(addButton)
      addButton.snp_makeConstraints { (make) -> Void in
          make.edges.equalTo(self.contentView).priorityLow()
      }
  }
}

How can I fix this issue?

Autolayout issues on iOS7

If you run app on iOS7 simulator, you will get this one:

Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSLayoutConstraint:0x7fa87179cf90 H:|-(16)-[UILabel:0x7fa87179b200]   (Names: '|':UITableViewCellContentView:0x7fa87179b120 )>",
    "<NSLayoutConstraint:0x7fa87179d080 H:[UIImageView:0x7fa87179cb80]-(>=16)-|   (Names: '|':UITableViewCellContentView:0x7fa87179b120 )>",
    "<NSLayoutConstraint:0x7fa87179d120 UIImageView:0x7fa87179cb80.leading == UILabel:0x7fa87179b200.leading>",
    "<NSAutoresizingMaskLayoutConstraint:0x7fa87179e530 h=--& v=--& H:[UITableViewCellContentView:0x7fa87179b120(0)]>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x7fa87179d120 UIImageView:0x7fa87179cb80.leading == UILabel:0x7fa87179b200.leading>```

Is surport ios6?

I has tested it on iOS 6, It can not calculate the rowHeight correctly, but I have read your blog. You said it can surpot ios6,I have delete "self.tableView.estimatedRowHeight = 200;”

调用reloadSections会崩溃

(void)fd_reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation

NSMutableArray *rows = self.fd_cellHeightCache.sections[idx];
运行到这句话崩溃,调用如下:

[_displayTableView reloadSections:[NSIndexSet indexSetWithIndex:0] withRowAnimation:UITableViewRowAnimationFade];

ImageView size

How to use with image from internet download asynchronies when set content of cell. Size of the image may already known

请教一个问题

请问- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath这个方法是不是会调用两次呢?

微信朋友圈布局autolayout

我想问下,就是类似微信朋友圈的那种布局,九张图片如果使用autolayout怎么添加约束,我现在是用一个View来做这几张图片的背景,但是用添加约束之后,使用autolayout,高度并没有发生改变。

Too slow on 'big' tables even with cacheByIndexPath

In my app I usually have tables with ~150 rows.
Rows are very simple:
screen shot 2015-04-30 at 3 11 47 am

When table view creates I have delay for about 3 seconds before it appears (iPhone 5 iOS 8.3)...
I tried to use new - (CGFloat)fd_heightForCellWithIdentifier:(NSString *)identifier cacheByIndexPath:(NSIndexPath *)indexPath configuration:(void (^)(id cell))configuration; But seems like it starts caching heights only when I scroll through them for second time.

Also I noticed that - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath is called 3 times on init stage and all these 3 times heights are calculated from scratch... Here's my implementation:

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"step 1: %@", indexPath);
    return [tableView fd_heightForCellWithIdentifier:@"DetailViewTableViewCell" cacheByIndexPath:indexPath configuration:^(iptvDetailedEPGTableViewCell *cell) {
        // Configure this cell with data, same as what you've done in "-tableView:cellForRowAtIndexPath:"
        NSLog(@"step 2: %@", indexPath); // Should not be called if using cached height, right?
        [self configureCell:cell forIndexPath:indexPath];
    }];
}

I get both log messages (3 * table length) times at init and than 1 more time when scrolling through the tableView. Only when scrolling second time I see only 1 log message.

Is it normal behaviour?

Thanks.

Why explicitly call systemLayoutSizeFittingSize

I remember the auto layout engine will calculate the frame based on the constraints, why you explicitly call systemLayoutSizeFittingSize?

I tried to delete the delegate and it turned out the imageView's constraint is still the same, but the height is half of the height constraint, and the image itself size is not fully occupied, so I am thinking, will this be a bug for your imageView not correctly set?

For exmaple, in the phil cell with the beauty's image, size is 160,97, while constraint is 160,195 and alignment rect is 160,195 as well.
If set the delegate, the size is 160,195, constraint 160,195, alignment rect 160,195.

imagesize

隐藏某个控件

cell 从上到下有一个label,一个scroll view, 另外一个label。scroll view在没有内容的时候,会隐藏起来。这种情况下,似乎高度还是会算上scroll view,导致中间空白。有解决办法吗?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.