Skip to content

Commit 0c47ec7

Browse files
author
norsez
committed
add demo for the additional API
1 parent 263ce9c commit 0c47ec7

File tree

4 files changed

+23
-12
lines changed

4 files changed

+23
-12
lines changed

BDDynamicGridViewDemo/BDViewController+Private.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@
1010

1111
@interface BDViewController (Private)
1212
- (void) _demoAsyncDataLoading;
13+
- (void) buildBarButtons;
1314
@end

BDDynamicGridViewDemo/BDViewController+Private.m

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,18 @@
1010
#define kNumberOfPhotos 25
1111
@implementation BDViewController (Private)
1212

13+
-(void)buildBarButtons
14+
{
15+
UIBarButtonItem * reloadButton = [[UIBarButtonItem alloc] initWithTitle:@"Lay it!"
16+
style:UIBarButtonItemStylePlain
17+
target:self
18+
action:@selector(animateReload)];
19+
20+
21+
self.navigationItem.rightBarButtonItems = [NSArray arrayWithObjects: reloadButton, nil];
22+
23+
}
24+
1325
-(NSArray*)_imagesFromBundle
1426
{
1527
NSArray *images = [NSArray array];
@@ -60,6 +72,11 @@ - (void) animateUpdate:(NSArray*)objects
6072
[UIView animateWithDuration:0.5
6173
animations:^{
6274
imageView.alpha = 1;
75+
} completion:^(BOOL finished) {
76+
NSArray *visibleRowInfos = [self visibleRowInfos];
77+
for (BDRowInfo *rowInfo in visibleRowInfos) {
78+
[self updateLayoutWithRow:rowInfo animiated:YES];
79+
}
6380
}];
6481
}];
6582
}

BDDynamicGridViewDemo/BDViewController.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#import <UIKit/UIKit.h>
1010
#import "BDDynamicGridViewController.h"
1111
@interface BDViewController : BDDynamicGridViewController <BDDynamicGridViewDelegate>{
12-
NSArray * _items;
12+
NSArray * _items;
1313
}
1414

1515
@end

BDDynamicGridViewDemo/BDViewController.m

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#import "BDViewController+Private.h"
1111
#import "BDRowInfo.h"
1212
@interface BDViewController (){
13-
1413
}
14+
1515
@end
1616

1717
@implementation BDViewController
@@ -28,14 +28,8 @@ - (void)viewDidLoad
2828
self.onDoubleTap = ^(UIView* view, NSInteger viewIndex){
2929
NSLog(@"Double tap on %@, at %d", view, viewIndex);
3030
};
31-
[super viewDidLoad];
3231
[self _demoAsyncDataLoading];
33-
34-
UIBarButtonItem * reloadButton = [[UIBarButtonItem alloc] initWithTitle:@"Lay it!"
35-
style:UIBarButtonItemStylePlain
36-
target:self
37-
action:@selector(animateReload)];
38-
self.navigationItem.rightBarButtonItem = reloadButton;
32+
[self buildBarButtons];
3933
}
4034

4135
- (void)animateReload
@@ -44,18 +38,17 @@ - (void)animateReload
4438
[self _demoAsyncDataLoading];
4539
}
4640

47-
4841
- (NSUInteger)numberOfViews
4942
{
5043
return _items.count;
5144
}
5245

53-
- (NSUInteger)maximumViewsPerCell
46+
-(NSUInteger)maximumViewsPerCell
5447
{
5548
return 5;
5649
}
5750

58-
- (UIView *)viewAtIndex:(NSUInteger)index
51+
- (UIView *)viewAtIndex:(NSUInteger)index rowInfo:(BDRowInfo *)rowInfo
5952
{
6053
UIImageView * imageView = [_items objectAtIndex:index];
6154
return imageView;

0 commit comments

Comments
 (0)