Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Initial commit

  • Loading branch information...
commit 84a79665ea1df5ea85b1a548d0aa8456882fa01f 0 parents
@dongle authored
12 .gitignore
@@ -0,0 +1,12 @@
+.DS_Store
+*.swp
+*~.nib
+
+build/
+
+.xcodeproj/
+!*.xcodeproj/project.pbxproj
+*.mode1v3
+*.mode2v3
+
+xcuserdata
65 DIYAssetPicker/DIYAssetPickerController.h
@@ -0,0 +1,65 @@
+//
+// DIYAssetPickerController.h
+// DIYAssetPicker
+//
+// Created by Jonathan Beilin on 7/30/12.
+// Copyright (c) 2012 Jonathan Beilin. All rights reserved.
+//
+// Some code based on PhotoPickerPlus
+
+#import <UIKit/UIKit.h>
+#import <AssetsLibrary/AssetsLibrary.h>
+
+#define THUMB_COUNT_PER_ROW ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? 6 : 4)
+
+#define MIN_THUMB_SPACING ((UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) ? 4 : 1)
+
+#define MAX_THUMB_SIZE 100
+//thumb size greater than 100 will cause blurriness adjust greater at own risk.
+
+#define THUMB_SIZE (MIN(floor((self.assetsTable.frame.size.width-(MIN_THUMB_SPACING*(THUMB_COUNT_PER_ROW+1)))/THUMB_COUNT_PER_ROW),MAX_THUMB_SIZE))
+
+#define THUMB_SPACING (MAX(floor((self.assetsTable.frame.size.width-(THUMB_COUNT_PER_ROW*THUMB_SIZE))/(THUMB_COUNT_PER_ROW+1)),MIN_THUMB_SPACING))
+
+@class DIYAssetPickerController;
+
+@protocol DIYAssetPickerControllerDelegate
+- (void)pickerDidCancel:(DIYAssetPickerController *)picker;
+- (void)pickerDidFinishPickingWithInfo:(NSDictionary *)info;
+@end
+
+// Should these be masks? Not enough options to make a big difference
+
+typedef enum {
+ DIYAssetPickerLandscape,
+ DIYAssetPickerPortrait,
+ DIYAssetPickerPortraitLandscape
+} DIYAssetPickerControllerOrientation;
+
+typedef enum {
+ DIYAssetPickerPhoto,
+ DIYAssetPickerVideo,
+ DIYAssetPickerPhotoVideo
+} DIYAssetPickerControllerAssetType;
+
+@interface DIYAssetPickerController : UIViewController <UITableViewDataSource, UITableViewDelegate>
+{
+ @private ALAssetsLibrary *_assetsLibrary;
+ @private NSMutableArray *_allAssets;
+ @private UITableView *_assetsTable;
+ @private UINavigationBar *_header;
+}
+
+#pragma mark - Delegate
+@property (assign) id delegate;
+
+#pragma mark - UI
+// transparent top bar with title?
+// blue dismiss button
+
+#pragma mark - Options
+@property (nonatomic, assign) int numberColumns;
+@property (nonatomic, assign) DIYAssetPickerControllerAssetType assetType;
+@property (nonatomic, assign) DIYAssetPickerControllerOrientation validOrientation;
+
+@end
184 DIYAssetPicker/DIYAssetPickerController.m
@@ -0,0 +1,184 @@
+//
+// DIYAssetPickerController.m
+// DIYAssetPicker
+//
+// Created by Jonathan Beilin on 7/30/12.
+// Copyright (c) 2012 Jonathan Beilin. All rights reserved.
+//
+
+#import "DIYAssetPickerController.h"
+
+@interface DIYAssetPickerController ()
+@property (nonatomic, retain) ALAssetsLibrary *assetsLibrary;
+@property (nonatomic, copy) NSMutableArray *allAssets;
+@property (nonatomic, retain) UITableView *assetsTable;
+@property (nonatomic, retain) UINavigationBar *header;
+@end
+
+@implementation DIYAssetPickerController
+
+@synthesize assetsLibrary = _assetsLibrary;
+@synthesize allAssets = _allAssets;
+@synthesize assetsTable = _assetsTable;
+@synthesize header = _header;
+
+@synthesize delegate = _delegate;
+@synthesize numberColumns = _numberColumns;
+@synthesize assetType = _assetType;
+@synthesize validOrientation = _validOrientation;
+
+#pragma mark - Init
+
+#pragma mark - View Lifecycle
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ // Setup
+ [self setTitle:@"Asset Picker"];
+
+ // Header
+ CGRect headerFrame = self.view.bounds;
+ _header = [[UINavigationBar alloc] initWithFrame:headerFrame];
+ headerFrame.size = [self.header sizeThatFits:headerFrame.size];
+ self.header.frame = headerFrame;
+ self.header.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+ self.header.barStyle = UIBarStyleBlack;
+ self.header.translucent = true;
+ [self.header setItems:@[ self.navigationItem ]];
+ [self.view addSubview:self.header];
+
+ // Asset library & array
+ self.assetsLibrary = [[[ALAssetsLibrary alloc] init] autorelease];
+
+ self.allAssets = [self getAssetsArray];
+
+ // Asset Table
+ _assetsTable = [[UITableView alloc] initWithFrame:self.view.bounds style:UITableViewStylePlain];
+ [self.assetsTable setContentInset:UIEdgeInsetsMake(self.header.frame.size.height, 0, 0, 0)];
+ [self.assetsTable setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth];
+ [self.assetsTable setDelegate:self];
+ [self.assetsTable setDataSource:self];
+ [self.assetsTable setSeparatorColor:[UIColor clearColor]];
+ [self.assetsTable setAllowsSelection:NO];
+ //[self.view addSubview:self.assetsTable];
+}
+
+- (void)viewDidDisappear:(BOOL)animated
+{
+ [super viewDidDisappear:animated];
+ [self releaseObjects];
+}
+
+/*
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+ */
+
+#pragma mark - UITableViewDelegate
+
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
+{
+ return 1;
+}
+
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
+{
+ /*
+ if(!photos) {
+ return 0;
+ }
+ return ceil([photos count]/((float)THUMB_COUNT_PER_ROW));
+ */
+
+ return 0;
+}
+
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ // TODO: borrowed code; refactor if necessary
+ static NSString *CellIdentifier = @"Cell";
+
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
+ if (cell == nil) {
+
+ cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
+ }
+ [cell.textLabel setText:@" "];
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^(void) {
+ UIView *v = [self tableView:tableView viewForIndexPath:indexPath];
+ dispatch_async(dispatch_get_main_queue(), ^(void) {
+ if(v){
+ for(UIView *view in cell.contentView.subviews){
+ [view removeFromSuperview];
+ }
+ [cell.contentView addSubview:v];
+ }
+ else{
+ [cell setAccessoryType:UITableViewCellAccessoryNone];
+ [cell setEditingAccessoryType:UITableViewCellAccessoryNone];
+ }
+ });
+ });
+ return cell;
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ return THUMB_SPACING + THUMB_SIZE;
+}
+
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ [tableView deselectRowAtIndexPath:indexPath animated:NO];
+}
+
+- (UIView *)tableView:(UITableView *)tableView viewForIndexPath:(NSIndexPath *)indexPath
+{
+ // TODO: put actual stuff in here
+
+ return [[[UIView alloc] initWithFrame:CGRectMake(0, 0, self.assetsTable.frame.size.width, [self tableView:self.assetsTable heightForRowAtIndexPath:indexPath])] autorelease];
+}
+
+#pragma mark - Utility
+
+- (NSArray *)getAssetsArray {
+ NSMutableArray *assets = [NSMutableArray array];
+ dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
+ [self.assetsLibrary
+ enumerateGroupsWithTypes:ALAssetsGroupSavedPhotos
+ usingBlock:^(ALAssetsGroup *group, BOOL *stop) {
+ [group enumerateAssetsUsingBlock:^(ALAsset *result, NSUInteger index, BOOL *stop) {
+ if (result) {
+ [self.allAssets addObject:result];
+ }
+ }];
+ }
+ failureBlock:^(NSError *error) {
+ // This is where I handle the case where the user has denied access
+ }];
+ });
+ return assets;
+}
+
+#pragma mark - Dealloc
+
+- (void)releaseObjects
+{
+ [_allAssets release]; _allAssets = nil;
+ [_assetsLibrary release]; _assetsLibrary = nil;
+ [_assetsTable release]; _assetsTable = nil;
+ [_header release]; _header = nil;
+
+ _delegate = nil;
+}
+
+- (void)dealloc
+{
+ [super dealloc];
+}
+
+@end
298 Example/DIYAssetPicker.xcodeproj/project.pbxproj
@@ -0,0 +1,298 @@
+// !$*UTF8*$!
+{
+ archiveVersion = 1;
+ classes = {
+ };
+ objectVersion = 46;
+ objects = {
+
+/* Begin PBXBuildFile section */
+ DE25877415CA0152002657BD /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE25877315CA0152002657BD /* UIKit.framework */; };
+ DE25877615CA0152002657BD /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE25877515CA0152002657BD /* Foundation.framework */; };
+ DE25877815CA0152002657BD /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DE25877715CA0152002657BD /* CoreGraphics.framework */; };
+ DE25877E15CA0152002657BD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = DE25877C15CA0152002657BD /* InfoPlist.strings */; };
+ DE25878015CA0152002657BD /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DE25877F15CA0152002657BD /* main.m */; };
+ DE25878415CA0152002657BD /* DIYAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DE25878315CA0152002657BD /* DIYAppDelegate.m */; };
+ DE5C71F815CA01D1006C1567 /* DIYAssetPickerController.m in Sources */ = {isa = PBXBuildFile; fileRef = DE5C71F615CA01D1006C1567 /* DIYAssetPickerController.m */; };
+ DE5C720115CA057C006C1567 /* DIYViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = DE5C71FF15CA057C006C1567 /* DIYViewController.m */; };
+ DE5C720215CA057C006C1567 /* DIYViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DE5C720015CA057C006C1567 /* DIYViewController.xib */; };
+ DEB87F6B15CA34A70080638C /* AssetsLibrary.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DEB87F6A15CA34A70080638C /* AssetsLibrary.framework */; };
+/* End PBXBuildFile section */
+
+/* Begin PBXFileReference section */
+ DE25876F15CA0152002657BD /* DIYAssetPicker.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = DIYAssetPicker.app; sourceTree = BUILT_PRODUCTS_DIR; };
+ DE25877315CA0152002657BD /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; };
+ DE25877515CA0152002657BD /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
+ DE25877715CA0152002657BD /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
+ DE25877B15CA0152002657BD /* DIYAssetPicker-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "DIYAssetPicker-Info.plist"; sourceTree = "<group>"; };
+ DE25877D15CA0152002657BD /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
+ DE25877F15CA0152002657BD /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
+ DE25878115CA0152002657BD /* DIYAssetPicker-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "DIYAssetPicker-Prefix.pch"; sourceTree = "<group>"; };
+ DE25878215CA0152002657BD /* DIYAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = DIYAppDelegate.h; sourceTree = "<group>"; };
+ DE25878315CA0152002657BD /* DIYAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = DIYAppDelegate.m; sourceTree = "<group>"; };
+ DE5C71F515CA01D1006C1567 /* DIYAssetPickerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DIYAssetPickerController.h; sourceTree = "<group>"; };
+ DE5C71F615CA01D1006C1567 /* DIYAssetPickerController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DIYAssetPickerController.m; sourceTree = "<group>"; };
+ DE5C71FE15CA057C006C1567 /* DIYViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DIYViewController.h; sourceTree = "<group>"; };
+ DE5C71FF15CA057C006C1567 /* DIYViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DIYViewController.m; sourceTree = "<group>"; };
+ DE5C720015CA057C006C1567 /* DIYViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = DIYViewController.xib; sourceTree = "<group>"; };
+ DEB87F6A15CA34A70080638C /* AssetsLibrary.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AssetsLibrary.framework; path = System/Library/Frameworks/AssetsLibrary.framework; sourceTree = SDKROOT; };
+/* End PBXFileReference section */
+
+/* Begin PBXFrameworksBuildPhase section */
+ DE25876C15CA0152002657BD /* Frameworks */ = {
+ isa = PBXFrameworksBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DEB87F6B15CA34A70080638C /* AssetsLibrary.framework in Frameworks */,
+ DE25877415CA0152002657BD /* UIKit.framework in Frameworks */,
+ DE25877615CA0152002657BD /* Foundation.framework in Frameworks */,
+ DE25877815CA0152002657BD /* CoreGraphics.framework in Frameworks */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXFrameworksBuildPhase section */
+
+/* Begin PBXGroup section */
+ DE25876415CA0152002657BD = {
+ isa = PBXGroup;
+ children = (
+ DE5C71F415CA01D1006C1567 /* DIYAssetPicker */,
+ DE25877915CA0152002657BD /* Example */,
+ DE25877215CA0152002657BD /* Frameworks */,
+ DE25877015CA0152002657BD /* Products */,
+ );
+ sourceTree = "<group>";
+ };
+ DE25877015CA0152002657BD /* Products */ = {
+ isa = PBXGroup;
+ children = (
+ DE25876F15CA0152002657BD /* DIYAssetPicker.app */,
+ );
+ name = Products;
+ sourceTree = "<group>";
+ };
+ DE25877215CA0152002657BD /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ DEB87F6A15CA34A70080638C /* AssetsLibrary.framework */,
+ DE25877315CA0152002657BD /* UIKit.framework */,
+ DE25877515CA0152002657BD /* Foundation.framework */,
+ DE25877715CA0152002657BD /* CoreGraphics.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "<group>";
+ };
+ DE25877915CA0152002657BD /* Example */ = {
+ isa = PBXGroup;
+ children = (
+ DE25878215CA0152002657BD /* DIYAppDelegate.h */,
+ DE25878315CA0152002657BD /* DIYAppDelegate.m */,
+ DE5C71FE15CA057C006C1567 /* DIYViewController.h */,
+ DE5C71FF15CA057C006C1567 /* DIYViewController.m */,
+ DE5C720015CA057C006C1567 /* DIYViewController.xib */,
+ DE25877A15CA0152002657BD /* Supporting Files */,
+ );
+ name = Example;
+ path = DIYAssetPicker;
+ sourceTree = "<group>";
+ };
+ DE25877A15CA0152002657BD /* Supporting Files */ = {
+ isa = PBXGroup;
+ children = (
+ DE25877B15CA0152002657BD /* DIYAssetPicker-Info.plist */,
+ DE25877C15CA0152002657BD /* InfoPlist.strings */,
+ DE25877F15CA0152002657BD /* main.m */,
+ DE25878115CA0152002657BD /* DIYAssetPicker-Prefix.pch */,
+ );
+ name = "Supporting Files";
+ sourceTree = "<group>";
+ };
+ DE5C71F415CA01D1006C1567 /* DIYAssetPicker */ = {
+ isa = PBXGroup;
+ children = (
+ DE5C71F515CA01D1006C1567 /* DIYAssetPickerController.h */,
+ DE5C71F615CA01D1006C1567 /* DIYAssetPickerController.m */,
+ );
+ name = DIYAssetPicker;
+ path = ../DIYAssetPicker;
+ sourceTree = "<group>";
+ };
+/* End PBXGroup section */
+
+/* Begin PBXNativeTarget section */
+ DE25876E15CA0152002657BD /* DIYAssetPicker */ = {
+ isa = PBXNativeTarget;
+ buildConfigurationList = DE25878715CA0152002657BD /* Build configuration list for PBXNativeTarget "DIYAssetPicker" */;
+ buildPhases = (
+ DE25876B15CA0152002657BD /* Sources */,
+ DE25876C15CA0152002657BD /* Frameworks */,
+ DE25876D15CA0152002657BD /* Resources */,
+ );
+ buildRules = (
+ );
+ dependencies = (
+ );
+ name = DIYAssetPicker;
+ productName = DIYAssetPicker;
+ productReference = DE25876F15CA0152002657BD /* DIYAssetPicker.app */;
+ productType = "com.apple.product-type.application";
+ };
+/* End PBXNativeTarget section */
+
+/* Begin PBXProject section */
+ DE25876615CA0152002657BD /* Project object */ = {
+ isa = PBXProject;
+ attributes = {
+ CLASSPREFIX = DIY;
+ LastUpgradeCheck = 0440;
+ ORGANIZATIONNAME = "Jonathan Beilin";
+ };
+ buildConfigurationList = DE25876915CA0152002657BD /* Build configuration list for PBXProject "DIYAssetPicker" */;
+ compatibilityVersion = "Xcode 3.2";
+ developmentRegion = English;
+ hasScannedForEncodings = 0;
+ knownRegions = (
+ en,
+ );
+ mainGroup = DE25876415CA0152002657BD;
+ productRefGroup = DE25877015CA0152002657BD /* Products */;
+ projectDirPath = "";
+ projectRoot = "";
+ targets = (
+ DE25876E15CA0152002657BD /* DIYAssetPicker */,
+ );
+ };
+/* End PBXProject section */
+
+/* Begin PBXResourcesBuildPhase section */
+ DE25876D15CA0152002657BD /* Resources */ = {
+ isa = PBXResourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DE25877E15CA0152002657BD /* InfoPlist.strings in Resources */,
+ DE5C720215CA057C006C1567 /* DIYViewController.xib in Resources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXResourcesBuildPhase section */
+
+/* Begin PBXSourcesBuildPhase section */
+ DE25876B15CA0152002657BD /* Sources */ = {
+ isa = PBXSourcesBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ DE25878015CA0152002657BD /* main.m in Sources */,
+ DE25878415CA0152002657BD /* DIYAppDelegate.m in Sources */,
+ DE5C71F815CA01D1006C1567 /* DIYAssetPickerController.m in Sources */,
+ DE5C720115CA057C006C1567 /* DIYViewController.m in Sources */,
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ };
+/* End PBXSourcesBuildPhase section */
+
+/* Begin PBXVariantGroup section */
+ DE25877C15CA0152002657BD /* InfoPlist.strings */ = {
+ isa = PBXVariantGroup;
+ children = (
+ DE25877D15CA0152002657BD /* en */,
+ );
+ name = InfoPlist.strings;
+ sourceTree = "<group>";
+ };
+/* End PBXVariantGroup section */
+
+/* Begin XCBuildConfiguration section */
+ DE25878515CA0152002657BD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = NO;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_DYNAMIC_NO_PIC = NO;
+ GCC_OPTIMIZATION_LEVEL = 0;
+ GCC_PREPROCESSOR_DEFINITIONS = (
+ "DEBUG=1",
+ "$(inherited)",
+ );
+ GCC_SYMBOLS_PRIVATE_EXTERN = NO;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1;
+ SDKROOT = iphoneos;
+ };
+ name = Debug;
+ };
+ DE25878615CA0152002657BD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ ALWAYS_SEARCH_USER_PATHS = NO;
+ ARCHS = "$(ARCHS_STANDARD_32_BIT)";
+ CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
+ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
+ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
+ COPY_PHASE_STRIP = YES;
+ GCC_C_LANGUAGE_STANDARD = gnu99;
+ GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
+ GCC_WARN_ABOUT_RETURN_TYPE = YES;
+ GCC_WARN_UNINITIALIZED_AUTOS = YES;
+ GCC_WARN_UNUSED_VARIABLE = YES;
+ IPHONEOS_DEPLOYMENT_TARGET = 5.1;
+ OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1";
+ SDKROOT = iphoneos;
+ VALIDATE_PRODUCT = YES;
+ };
+ name = Release;
+ };
+ DE25878815CA0152002657BD /* Debug */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "DIYAssetPicker/DIYAssetPicker-Prefix.pch";
+ INFOPLIST_FILE = "DIYAssetPicker/DIYAssetPicker-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Debug;
+ };
+ DE25878915CA0152002657BD /* Release */ = {
+ isa = XCBuildConfiguration;
+ buildSettings = {
+ GCC_PRECOMPILE_PREFIX_HEADER = YES;
+ GCC_PREFIX_HEADER = "DIYAssetPicker/DIYAssetPicker-Prefix.pch";
+ INFOPLIST_FILE = "DIYAssetPicker/DIYAssetPicker-Info.plist";
+ PRODUCT_NAME = "$(TARGET_NAME)";
+ WRAPPER_EXTENSION = app;
+ };
+ name = Release;
+ };
+/* End XCBuildConfiguration section */
+
+/* Begin XCConfigurationList section */
+ DE25876915CA0152002657BD /* Build configuration list for PBXProject "DIYAssetPicker" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DE25878515CA0152002657BD /* Debug */,
+ DE25878615CA0152002657BD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+ DE25878715CA0152002657BD /* Build configuration list for PBXNativeTarget "DIYAssetPicker" */ = {
+ isa = XCConfigurationList;
+ buildConfigurations = (
+ DE25878815CA0152002657BD /* Debug */,
+ DE25878915CA0152002657BD /* Release */,
+ );
+ defaultConfigurationIsVisible = 0;
+ defaultConfigurationName = Release;
+ };
+/* End XCConfigurationList section */
+ };
+ rootObject = DE25876615CA0152002657BD /* Project object */;
+}
7 Example/DIYAssetPicker.xcodeproj/project.xcworkspace/contents.xcworkspacedata
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Workspace
+ version = "1.0">
+ <FileRef
+ location = "self:DIYAssetPicker.xcodeproj">
+ </FileRef>
+</Workspace>
19 Example/DIYAssetPicker/DIYAppDelegate.h
@@ -0,0 +1,19 @@
+//
+// DIYAppDelegate.h
+// DIYAssetPicker
+//
+// Created by Jonathan Beilin on 7/30/12.
+// Copyright (c) 2012 Jonathan Beilin. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+#import "DIYViewController.h"
+#import "DIYAssetPickerController.h"
+
+@interface DIYAppDelegate : UIResponder <UIApplicationDelegate>
+
+@property (strong, nonatomic) UIWindow *window;
+@property (strong, nonatomic) DIYViewController *viewController;
+@property (strong, nonatomic) DIYAssetPickerController *assetPicker;
+
+@end
70 Example/DIYAssetPicker/DIYAppDelegate.m
@@ -0,0 +1,70 @@
+//
+// DIYAppDelegate.m
+// DIYAssetPicker
+//
+// Created by Jonathan Beilin on 7/30/12.
+// Copyright (c) 2012 Jonathan Beilin. All rights reserved.
+//
+
+#import "DIYAppDelegate.h"
+
+@implementation DIYAppDelegate
+
+@synthesize viewController = _viewController;
+@synthesize assetPicker = _assetPicker;
+
+- (void)dealloc
+{
+ [_viewController release];
+ [_assetPicker release];
+ [_window release];
+ [super dealloc];
+}
+
+- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
+{
+ self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
+
+ self.window.backgroundColor = [UIColor whiteColor];
+
+ /*
+ _viewController = [[DIYViewController alloc] init];
+ [self.viewController presentModalViewController:self.assetPicker animated:YES];
+ self.window.rootViewController = self.viewController;
+ */
+
+ _assetPicker = [[DIYAssetPickerController alloc] init];
+ self.window.rootViewController = self.assetPicker;
+
+ [self.window makeKeyAndVisible];
+ return YES;
+}
+
+- (void)applicationWillResignActive:(UIApplication *)application
+{
+ // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
+ // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+}
+
+- (void)applicationDidEnterBackground:(UIApplication *)application
+{
+ // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
+ // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+}
+
+- (void)applicationWillEnterForeground:(UIApplication *)application
+{
+ // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+}
+
+- (void)applicationDidBecomeActive:(UIApplication *)application
+{
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+}
+
+- (void)applicationWillTerminate:(UIApplication *)application
+{
+ // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+}
+
+@end
38 Example/DIYAssetPicker/DIYAssetPicker-Info.plist
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+<dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleDisplayName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundleExecutable</key>
+ <string>${EXECUTABLE_NAME}</string>
+ <key>CFBundleIdentifier</key>
+ <string>DIY.${PRODUCT_NAME:rfc1034identifier}</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>${PRODUCT_NAME}</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>1.0</string>
+ <key>CFBundleSignature</key>
+ <string>????</string>
+ <key>CFBundleVersion</key>
+ <string>1.0</string>
+ <key>LSRequiresIPhoneOS</key>
+ <true/>
+ <key>UIRequiredDeviceCapabilities</key>
+ <array>
+ <string>armv7</string>
+ </array>
+ <key>UISupportedInterfaceOrientations</key>
+ <array>
+ <string>UIInterfaceOrientationPortrait</string>
+ <string>UIInterfaceOrientationLandscapeLeft</string>
+ <string>UIInterfaceOrientationLandscapeRight</string>
+ </array>
+</dict>
+</plist>
14 Example/DIYAssetPicker/DIYAssetPicker-Prefix.pch
@@ -0,0 +1,14 @@
+//
+// Prefix header for all source files of the 'DIYAssetPicker' target in the 'DIYAssetPicker' project
+//
+
+#import <Availability.h>
+
+#ifndef __IPHONE_3_0
+#warning "This project uses features only available in iOS SDK 3.0 and later."
+#endif
+
+#ifdef __OBJC__
+ #import <UIKit/UIKit.h>
+ #import <Foundation/Foundation.h>
+#endif
13 Example/DIYAssetPicker/DIYViewController.h
@@ -0,0 +1,13 @@
+//
+// DIYViewController.h
+// DIYAssetPicker
+//
+// Created by Jonathan Beilin on 8/1/12.
+// Copyright (c) 2012 Jonathan Beilin. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface DIYViewController : UIViewController
+
+@end
44 Example/DIYAssetPicker/DIYViewController.m
@@ -0,0 +1,44 @@
+//
+// DIYViewController.m
+// DIYAssetPicker
+//
+// Created by Jonathan Beilin on 8/1/12.
+// Copyright (c) 2012 Jonathan Beilin. All rights reserved.
+//
+
+#import "DIYViewController.h"
+
+@interface DIYViewController ()
+
+@end
+
+@implementation DIYViewController
+
+- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
+{
+ self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
+ if (self) {
+ // Custom initialization
+ }
+ return self;
+}
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+ // Do any additional setup after loading the view from its nib.
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+ // Release any retained subviews of the main view.
+ // e.g. self.myOutlet = nil;
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
+{
+ return (interfaceOrientation == UIInterfaceOrientationPortrait);
+}
+
+@end
118 Example/DIYAssetPicker/DIYViewController.xib
@@ -0,0 +1,118 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00">
+ <data>
+ <int key="IBDocument.SystemTarget">1280</int>
+ <string key="IBDocument.SystemVersion">11C25</string>
+ <string key="IBDocument.InterfaceBuilderVersion">1919</string>
+ <string key="IBDocument.AppKitVersion">1138.11</string>
+ <string key="IBDocument.HIToolboxVersion">566.00</string>
+ <object class="NSMutableDictionary" key="IBDocument.PluginVersions">
+ <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="NS.object.0">916</string>
+ </object>
+ <array key="IBDocument.IntegratedClassDependencies">
+ <string>IBProxyObject</string>
+ <string>IBUIView</string>
+ </array>
+ <array key="IBDocument.PluginDependencies">
+ <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </array>
+ <object class="NSMutableDictionary" key="IBDocument.Metadata">
+ <string key="NS.key.0">PluginDependencyRecalculationVersion</string>
+ <integer value="1" key="NS.object.0"/>
+ </object>
+ <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
+ <object class="IBProxyObject" id="372490531">
+ <string key="IBProxiedObjectIdentifier">IBFilesOwner</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBProxyObject" id="975951072">
+ <string key="IBProxiedObjectIdentifier">IBFirstResponder</string>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ <object class="IBUIView" id="191373211">
+ <reference key="NSNextResponder"/>
+ <int key="NSvFlags">274</int>
+ <string key="NSFrame">{{0, 20}, {320, 460}}</string>
+ <reference key="NSSuperview"/>
+ <reference key="NSWindow"/>
+ <object class="NSColor" key="IBUIBackgroundColor">
+ <int key="NSColorSpace">3</int>
+ <bytes key="NSWhite">MQA</bytes>
+ <object class="NSColorSpace" key="NSCustomColorSpace">
+ <int key="NSID">2</int>
+ </object>
+ </object>
+ <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ </object>
+ </array>
+ <object class="IBObjectContainer" key="IBDocument.Objects">
+ <array class="NSMutableArray" key="connectionRecords">
+ <object class="IBConnectionRecord">
+ <object class="IBCocoaTouchOutletConnection" key="connection">
+ <string key="label">view</string>
+ <reference key="source" ref="372490531"/>
+ <reference key="destination" ref="191373211"/>
+ </object>
+ <int key="connectionID">3</int>
+ </object>
+ </array>
+ <object class="IBMutableOrderedSet" key="objectRecords">
+ <array key="orderedObjects">
+ <object class="IBObjectRecord">
+ <int key="objectID">0</int>
+ <array key="object" id="0"/>
+ <reference key="children" ref="1000"/>
+ <nil key="parent"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">1</int>
+ <reference key="object" ref="191373211"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-1</int>
+ <reference key="object" ref="372490531"/>
+ <reference key="parent" ref="0"/>
+ <string key="objectName">File's Owner</string>
+ </object>
+ <object class="IBObjectRecord">
+ <int key="objectID">-2</int>
+ <reference key="object" ref="975951072"/>
+ <reference key="parent" ref="0"/>
+ </object>
+ </array>
+ </object>
+ <dictionary class="NSMutableDictionary" key="flattenedProperties">
+ <string key="-1.CustomClassName">DIYViewController</string>
+ <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="-2.CustomClassName">UIResponder</string>
+ <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string>
+ </dictionary>
+ <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
+ <nil key="activeLocalization"/>
+ <dictionary class="NSMutableDictionary" key="localizations"/>
+ <nil key="sourceID"/>
+ <int key="maxID">3</int>
+ </object>
+ <object class="IBClassDescriber" key="IBDocument.Classes">
+ <array class="NSMutableArray" key="referencedPartialClassDescriptions">
+ <object class="IBPartialClassDescription">
+ <string key="className">DIYViewController</string>
+ <string key="superclassName">UIViewController</string>
+ <object class="IBClassDescriptionSource" key="sourceIdentifier">
+ <string key="majorKey">IBProjectSource</string>
+ <string key="minorKey">./Classes/DIYViewController.h</string>
+ </object>
+ </object>
+ </array>
+ </object>
+ <int key="IBDocument.localizationMode">0</int>
+ <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string>
+ <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
+ <int key="IBDocument.defaultPropertyAccessControl">3</int>
+ <string key="IBCocoaTouchPluginVersion">916</string>
+ </data>
+</archive>
2  Example/DIYAssetPicker/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
+/* Localized versions of Info.plist keys */
+
18 Example/DIYAssetPicker/main.m
@@ -0,0 +1,18 @@
+//
+// main.m
+// DIYAssetPicker
+//
+// Created by Jonathan Beilin on 8/1/12.
+// Copyright (c) 2012 Jonathan Beilin. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+#import "DIYAppDelegate.h"
+
+int main(int argc, char *argv[])
+{
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([DIYAppDelegate class]));
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.