Skip to content

Commit

Permalink
fix layout bug in CLCGCell and add CLCG_INCONSISTENCY macro
Browse files Browse the repository at this point in the history
  • Loading branch information
ettore committed Mar 2, 2015
1 parent c1ed878 commit ab9ba35
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
1 change: 0 additions & 1 deletion CLCGCell.h
Expand Up @@ -63,7 +63,6 @@

// properties declared in CLCGCell protocol
@property(nonatomic,assign) BOOL emphasized;
@property(nonatomic,readonly) CGFloat viewportPadding;
@property(nonatomic) CGFloat innerPadding;
@property(nonatomic,retain) UIColor *normalColor;
@property(nonatomic,retain) UIColor *emphasisColor;
Expand Down
5 changes: 3 additions & 2 deletions CLCGCell.m
Expand Up @@ -92,7 +92,7 @@ -(id)initWithImageWidth:(CGFloat)w
if (self) {
_imgW = w;
_imgH = h;
_viewportPadding = _innerPadding = padding;
_innerPadding = padding;
[self setCommonLayouter:[[CLCGCellCommonLayouter alloc] initWithCell:self]];
[self setSelectionStyle:UITableViewCellSelectionStyleBlue];
[[self textLabel] setTextColor:[UIColor blackColor]];
Expand Down Expand Up @@ -176,7 +176,7 @@ -(void)layoutSubviews
[super layoutSubviews];

// layout image view
const CGRect img_frame = CGRectMake(_viewportPadding, [class topBottomPadding],
const CGRect img_frame = CGRectMake([class viewportPadding], [class topBottomPadding],
_imgW, _imgH);
[_mainImageView setFrame:img_frame];

Expand Down Expand Up @@ -348,6 +348,7 @@ -(void)loadImageForURL:(NSString*)img_url
context:(id)cell_cxt_obj
{
[self setContext:cell_cxt_obj];
[self showImage:nil]; //avoid showing previous image on a recycled cell
[CLCGImageLoader loadImageForURL:img_url
retinaURL:retina_img_url
useCache:YES
Expand Down
3 changes: 1 addition & 2 deletions CLCGCellCommonLayouter.h
Expand Up @@ -53,12 +53,11 @@

@property(nonatomic,retain) UIView *backgroundView;
@property(nonatomic,readonly,retain) UIImageView *imageView NS_AVAILABLE_IOS(3_0);
- (void)setNeedsLayout;
@property(nonatomic,assign) BOOL emphasized;
@property(nonatomic,readonly) CGFloat viewportPadding;
@property(nonatomic,readonly) CGFloat innerPadding;
@property(nonatomic,retain) UIColor *normalColor;
@property(nonatomic,retain) UIColor *emphasisColor;
- (void)setNeedsDisplay;

@end

Expand Down
3 changes: 1 addition & 2 deletions CLCGCellCommonLayouter.m
Expand Up @@ -70,8 +70,7 @@ -(void)showImage:(UIImage*)img animated:(BOOL)animated
CALayer *layer = [[_cell imageView] layer];

if (animated) {
// once the img view has been layed out once, no need to re-lay it out again
[_cell setNeedsLayout]; //layout will happen in next update cycle
[_cell setNeedsDisplay];
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"opacity"];
[anim setDuration:0.4]; // seconds
[anim setFromValue:[NSNumber numberWithFloat:0.0]];
Expand Down
11 changes: 11 additions & 0 deletions clcg_debug.h
Expand Up @@ -101,6 +101,17 @@ if (am_i_being_debugged()) { __asm__("int $3\n" : : ); }; } \
#endif // #ifdef DEBUG
#define CLCGASSERT CLCG_ASSERT


///////////////////////////////////////////////////////////////////////////////
// exception macro

#ifdef DEBUG
#define CLCG_INCONSISTENCY(msg,obj) {[NSException raise:NSInternalInconsistencyException format:@"%@ Class: %@",msg,NSStringFromClass([obj class])];}
#else
#define CLCG_INCONSISTENCY(msg,obj) ((void)0)
#endif


#ifdef __cplusplus
}
#endif
Expand Down

0 comments on commit ab9ba35

Please sign in to comment.