Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added some preliminary demo stuff, added imageView property to cells

  • Loading branch information...
commit 087a37075af0d16796924b7b4682aa8013740f18 1 parent 68fd738
@kolinkrewinkel authored
View
8 Examples/GridViewDemo/GridViewDemo.xcodeproj/project.pbxproj
@@ -20,6 +20,7 @@
1A75378F148F070D00B8A777 /* KKGridViewIcon.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A75378D148F070D00B8A777 /* KKGridViewIcon.png */; };
1A753790148F070D00B8A777 /* KKGridViewIcon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A75378E148F070D00B8A777 /* KKGridViewIcon@2x.png */; };
1A753798148F1B6300B8A777 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 1A753796148F1B6300B8A777 /* Default.png */; };
+ 3330C714153536D90054B29A /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3330C713153536D90054B29A /* AssetsLibrary.framework */; };
397E3D281406642500C3DEA3 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 397E3D271406642500C3DEA3 /* QuartzCore.framework */; };
5674016D14AACDF300A838F8 /* KKGridView.bundle in Resources */ = {isa = PBXBuildFile; fileRef = 5674016C14AACDF300A838F8 /* KKGridView.bundle */; };
FC35C029149C70F100A56750 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = FC35C028149C70F100A56750 /* Default@2x.png */; };
@@ -45,6 +46,7 @@
1A75378D148F070D00B8A777 /* KKGridViewIcon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = KKGridViewIcon.png; sourceTree = "<group>"; };
1A75378E148F070D00B8A777 /* KKGridViewIcon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "KKGridViewIcon@2x.png"; sourceTree = "<group>"; };
1A753796148F1B6300B8A777 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Default.png; sourceTree = "<group>"; };
+ 3330C713153536D90054B29A /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
397E3D271406642500C3DEA3 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
5674016C14AACDF300A838F8 /* KKGridView.bundle */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.plug-in"; name = KKGridView.bundle; path = ../../../../KKGridView/KKGridView.bundle; sourceTree = "<group>"; };
FC35C028149C70F100A56750 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "Default@2x.png"; sourceTree = SOURCE_ROOT; };
@@ -57,10 +59,11 @@
buildActionMask = 2147483647;
files = (
1A72A97A1453B450002546F8 /* libKKGridView.a in Frameworks */,
+ 3330C714153536D90054B29A /* AssetsLibrary.framework in Frameworks */,
+ 1A530A3213DE962700E6C60B /* CoreGraphics.framework in Frameworks */,
+ 1A530A3013DE962700E6C60B /* Foundation.framework in Frameworks */,
397E3D281406642500C3DEA3 /* QuartzCore.framework in Frameworks */,
1A530A2E13DE962700E6C60B /* UIKit.framework in Frameworks */,
- 1A530A3013DE962700E6C60B /* Foundation.framework in Frameworks */,
- 1A530A3213DE962700E6C60B /* CoreGraphics.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -90,6 +93,7 @@
isa = PBXGroup;
children = (
1A72A9791453B450002546F8 /* libKKGridView.a */,
+ 3330C713153536D90054B29A /* AssetsLibrary.framework */,
1A530A3113DE962700E6C60B /* CoreGraphics.framework */,
1A530A2F13DE962700E6C60B /* Foundation.framework */,
397E3D271406642500C3DEA3 /* QuartzCore.framework */,
View
4 Examples/GridViewDemo/GridViewDemo.xcworkspace/xcshareddata/xcschemes/GridViewDemo.xcscheme
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
+ LastUpgradeVersion = "0440"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -53,11 +54,12 @@
</MacroExpansion>
</TestAction>
<LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<BuildableProductRunnable>
View
4 Examples/GridViewDemo/GridViewDemo.xcworkspace/xcshareddata/xcschemes/KKGridView.xcscheme
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
+ LastUpgradeVersion = "0440"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
@@ -30,11 +31,12 @@
</Testables>
</TestAction>
<LaunchAction
- selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.GDB"
+ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.GDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
buildConfiguration = "Debug"
+ ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
allowLocationSimulation = "YES">
<AdditionalOptions>
View
1  Examples/GridViewDemo/GridViewDemo/GridViewDemo-Prefix.pch
@@ -12,4 +12,5 @@
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#import <KKGridView/KKGridView.h>
+ #import <AssetsLibrary/AssetsLibrary.h>
#endif
View
98 Examples/GridViewDemo/GridViewDemo/GridViewDemoViewController.m
@@ -14,7 +14,14 @@
static const NSUInteger kNumSection = 40;
-@implementation GridViewDemoViewController
+@implementation GridViewDemoViewController {
+ ALAssetsLibrary *_assetsLibrary;
+ NSMutableArray *_photoGroups;
+ NSMutableArray *_assets;
+ NSDictionary *_thumbnailCache;
+ dispatch_queue _imageQueue;
+}
+
@synthesize firstSectionCount = _firstSectionCount;
#pragma mark - View lifecycle
@@ -23,70 +30,53 @@ - (void)loadView
{
[super loadView];
- _firstSectionCount = 7;
-
- UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0.f, 0.f, 320.f, 44.f)];
- searchBar.barStyle = UIBarStyleBlackTranslucent;
- searchBar.delegate = self;
- searchBar.showsCancelButton = YES;
- searchBar.userInteractionEnabled = YES;
- self.gridView.gridHeaderView = searchBar;
-
- UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0.f, 0.f, 20.f, 50.f)];
- footerView.backgroundColor = [UIColor darkGrayColor];
- self.gridView.gridFooterView = footerView;
+ _assetsLibrary = [[ALAssetsLibrary alloc] init];
+ [_assetsLibrary enumerateGroupsWithTypes:ALAssetsGroupAll usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
+ if (!_photoGroups)
+ _photoGroups = [[NSMutableArray alloc] init];
+
+ if (group)
+ [_photoGroups addObject:group];
+ else {
+ for (ALAssetsGroup *group in _photoGroups) {
+ if (!_assets)
+ _assets = [[NSMutableArray alloc] init];
+
+ NSMutableArray *tempArray = [[NSMutableArray alloc] init];
+ [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
+ if (result)
+ [tempArray addObject:result];
+ }];
+ [_assets addObject:tempArray];
+ }
+ [self.gridView reloadData];
+ }
+
+ } failureBlock:^(NSError *error) {
+ UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"LOLWAT" message:[NSString stringWithFormat:@"%@", [error localizedDescription]] delegate:nil cancelButtonTitle:@"Dismiss" otherButtonTitles:nil];
+ [alert show];
+ }];
- self.navigationController.toolbarHidden = NO;
- self.navigationController.navigationBarHidden = YES;
- self.navigationController.toolbar.tintColor = [UIColor darkGrayColor];
+ self.title = @"Photos | GridViewDemo";
- UIBarButtonItem *spacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
- UIBarButtonItem *add = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(addItems:)];
- UIBarButtonItem *remove = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(removeItems:)];
- UIBarButtonItem *multiple = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(toggleSelectionStyle:)];
-// UIBarButtonItem *move = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemOrganize target:self action:@selector(moveItems:)];
-
- self.toolbarItems = [NSArray arrayWithObjects:add, spacer, remove, spacer, spacer, multiple, nil];
}
#pragma mark - KKGridViewDataSource
- (NSUInteger)numberOfSectionsInGridView:(KKGridView *)gridView
{
- return kNumSection;
+ return _photoGroups.count;
}
- (NSUInteger)gridView:(KKGridView *)gridView numberOfItemsInSection:(NSUInteger)section
{
- switch (section) {
- case 0:
- return self.firstSectionCount;
- break;
- case 1:
- return 15;
- break;
- case 2:
- return 10;
- break;
- case 3:
- return 5;
- break;
- default:
- return (section % 2) ? 4 : 7;
- break;
- }
+ return [[_photoGroups objectAtIndex:section] numberOfAssets];
}
- (KKGridViewCell *)gridView:(KKGridView *)gridView cellForItemAtIndexPath:(KKIndexPath *)indexPath
{
KKGridViewCell *cell = [KKGridViewCell cellForGridView:gridView];
- if (indexPath.index % 2) {
- cell.accessoryType = KKGridViewCellAccessoryTypeUnread;
- } else {
- cell.accessoryType = KKGridViewCellAccessoryTypeReadPartial;
- }
- cell.accessoryPosition = KKGridViewCellAccessoryPositionTopLeft;
- cell.contentView.backgroundColor = [UIColor lightGrayColor];
+ cell.imageView.image = [UIImage imageWithCGImage:[[[_assets objectAtIndex:indexPath.section] objectAtIndex:indexPath.index] thumbnail]];
return cell;
}
@@ -96,19 +86,9 @@ - (CGFloat)gridView:(KKGridView *)gridView heightForHeaderInSection:(NSUInteger)
return 25.f;
}
-- (CGFloat)gridView:(KKGridView *)gridView heightForFooterInSection:(NSUInteger)section
-{
- return 25.f;
-}
-
- (NSString *)gridView:(KKGridView *)gridView titleForHeaderInSection:(NSUInteger)section
{
- return [NSString stringWithFormat:@"Header %i",section];
-}
-
-- (NSString *)gridView:(KKGridView *)gridView titleForFooterInSection:(NSUInteger)section
-{
- return [NSString stringWithFormat:@"Footer %i",section];
+ return [[_photoGroups objectAtIndex:section] valueForProperty:ALAssetsGroupPropertyName];
}
- (NSArray *)sectionIndexTitlesForGridView:(KKGridView *)gridView {
View
4 KKGridView.xcodeproj/project.pbxproj
@@ -212,7 +212,7 @@
1A61BE0613DCAF1F00AB4243 /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 0420;
+ LastUpgradeCheck = 0440;
ORGANIZATIONNAME = "kxk design";
};
buildConfigurationList = 1A61BE0913DCAF1F00AB4243 /* Build configuration list for PBXProject "KKGridView" */;
@@ -316,6 +316,7 @@
GCC_OPTIMIZATION_LEVEL = 0;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "KKGridView/KKGridView-Prefix.pch";
+ GCC_THUMB_SUPPORT = NO;
INSTALL_PATH = "/../BuildProductsPath/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
OTHER_LDFLAGS = (
@@ -341,6 +342,7 @@
CLANG_WARN_OBJCPP_ARC_ABI = YES;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "KKGridView/KKGridView-Prefix.pch";
+ GCC_THUMB_SUPPORT = NO;
INSTALL_PATH = "/../BuildProductsPath/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/";
IPHONEOS_DEPLOYMENT_TARGET = 4.0;
OTHER_LDFLAGS = (
View
1  KKGridView/KKGridViewCell.h
@@ -53,6 +53,7 @@ typedef enum {
@property (nonatomic, strong) IBOutlet UIView *backgroundView; // Underneath contentView, use this to customize backgrounds
@property (nonatomic, strong) IBOutlet UIView *contentView; // Where all subviews should be.
+@property (nonatomic, strong) IBOutlet UIImageView *imageView;
@property (nonatomic, copy) KKIndexPath *indexPath;
@property (nonatomic, copy) NSString *reuseIdentifier; // For usage by KKGridView
@property (nonatomic, getter = isSelected) BOOL selected;
View
6 KKGridView/KKGridViewCell.m
@@ -25,6 +25,7 @@ @implementation KKGridViewCell {
@synthesize accessoryType = _accessoryType;
@synthesize backgroundView = _backgroundView;
@synthesize contentView = _contentView;
+@synthesize imageView = _imageView;
@synthesize editing = _editing;
@synthesize indexPath = _indexPath;
@synthesize reuseIdentifier = _reuseIdentifier;
@@ -69,7 +70,10 @@ - (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
_contentView.backgroundColor = [UIColor whiteColor];
[self addSubview:_contentView];
[self addSubview:_selectedBackgroundView];
- [self bringSubviewToFront:_badgeView];
+
+ _imageView = [[UIImageView alloc] initWithFrame:self.bounds];
+ _imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
+ [self addSubview:_imageView];
[_contentView addObserver:self forKeyPath:@"backgroundColor" options:NSKeyValueObservingOptionNew context:NULL];
}
Please sign in to comment.
Something went wrong with that request. Please try again.